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__
  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?


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 ESRI_Version=ArcGIS10.3
SET ESRI_DIR=C:\Program Files (x86)\ArcGIS\Desktop10.3
SET PYTHONDIR=C:\Python27\%ESRI_Version%


PATH=%PATH%;%PYSC_DIR%;%PYSC_DIR%\Lib;%PYTHONDIR%;C:\Program Files (x86)\ArcGIS\EsriProductionMapping\Desktop10.3\Bin

start "PyScripter" "%PYSC_DIR%\PyScripter.exe" --python27

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.