2

I am setting up a new computer and installed ArcGIS 10.4 with Python 2.7.10. I then downloaded PyScripter to use as an editor. When I try import arcpy, I get the following error:

Traceback (most recent call last):
 File "<interactive input>", line 1, in <module>
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\__init__.py", line 22, in <module>
 from arcpy.geoprocessing import gp
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
 from _base import *
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", line 608, in <module>
 env = GPEnvironments(gp)
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", line 605, in GPEnvironments
 return GPEnvironment(geoprocessor)
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", line 561, in __init__
 self._refresh()
 File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", line 563, in _refresh
 envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized

I ensured that Python and PyScripter are both running 32 bit versions, ensured the paths were correct in PyScripter, tried setting the PYTHONPATH under the system environment settings, and I have tried suggestions found here but continue to get the same error. Any more suggestions?

asked Feb 8, 2017 at 15:42

2 Answers 2

3

I use a batch file, which i stored inside the folder where pyscripter.exe is. May you have to check and correct pathes for your arcgis installation (e.g. 10.3 -> 10.4).

@echo off
SET PYSC_DIR=%~dp0
SET ESRI_Version=ArcGIS10.3
SET ESRI_DIR=C:\Program Files (x86)\ArcGIS\Desktop10.3
SET PYTHONDIR=C:\Python27\%ESRI_Version%
SET PYTHONHOME=%PYTHONDIR%
SET PYTHONPATH=%PYSC_DIR%\Lib\rpyc.zip;%PYTHONPATH%
PATH=%PATH%;%PYSC_DIR%;%PYSC_DIR%\Lib;%PYTHONDIR%;C:\Program Files (x86)\ArcGIS\EsriProductionMapping\Desktop10.3\Bin
start "PyScripter" "%PYSC_DIR%\PyScripter.exe" --python27
answered Feb 8, 2017 at 16:31
1

In my case, I was not connected to network directly or thru VPN to validate ArcGIS License. Once I connected to network, the error "RuntimeError: NotInitialized" was resolved and my script ran successfully.

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
answered Jan 20, 2020 at 19:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.