Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

ArcGIS Version: ArcGIS 10, Python 2.6.5 Machine: Windows 7 64bit (Intel)

I'm receiving the following error when importing arcpy using the the IDLE (gui and cmd prompt) and when using pythonwin.

I had removed python26 and python25 from my system and have done a fresh install of ArcGIS 10 and python. Therefore am calling IDLE from here: "C:\Python26\ArcGIS10.0\pythonw.exe"

The Error:

**IDLE 2.6.5

import arcpy Traceback (most recent call last): File "", line 1, in import arcpy File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\", line 17, in from geoprocessing import gp File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 14, in from _base import * File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 568, in env = GPEnvironments(gp) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 565, in GPEnvironments return GPEnvironment(geoprocessor) File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 521, in init self._refresh() File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\", line 523, in _refresh envset = (set(env for env in self._gp.listEnvironments())) RuntimeError: NotInitialized**

EsriUK and Esri tech support have recommended fresh reinstall and registry edits = but this has not worked. I'm waiting on them for a solution.

I've investigated whether it was a module arcpy path issue. There are a couple of links on the Esri forums and on the ArcGIS help regarding paths. Also, a possible related thread on gis.stackexchange.

I followed the advise from 'kimo' on the Esri forum thread. But still the import error.

  1. My system variable (that I've edited) is: PYTHONPATH = "c:\python26";"C:\Python26\ArcGIS10.0";"C:\Python26\ArcGIS10.0\Lib\site-packages";"C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy"

  2. I have checked I have the contents of "C:\Python26\ArcGIS10.0\Lib\site-packages\Desktop10.pth". The contents are: C:\Program Files (x86)\ArcGIS\Desktop10.0\bin C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Scripts

However, the traceback message shows that a .py script is found in the folder: C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy. Therefore, suggests the arcpy module is found by the interpreter but then not initialized(?).

Arcpy can be called from the Python Window within ArcMap and ArcCatalog okay. It is only when called from a Python interpreter that the 'import arcpy' fails. Therefore, arcpy is initalized okay by ArcMap/ArcCatalog, but not IDLE - how can this be?

I previously had an install of python25, then python26 then after that upgraded to ArcGIS 10. Therefore, there was quite a lot of legacy python on my machine. However, I've uninstalled all and registry cleaned using ccleaner.

Can anyone suggest another line of enquiry as I'm not experienced with python enough to solve initialize/runtime errors? I'd like to avoid reinstalling the OS too!

share|improve this question
also posted on...… – Dan Patterson Feb 18 '11 at 14:22
This link helped me out. I added import arcserver before import arcpy line.… – G...... T...... Sep 15 '14 at 19:41

4 Answers 4

Looking at your posts here and on the ESRI Forums, I think you have some muddled environment settings.

You want to put C:\Python26\ArcGIS10.0 in your system PATH variable, that gets you to the correct executables from IDLE, PythonWin or the command line.

Your PYTHONPATH could be empty. Or, you could just include the 3 stanzas of your Desktop10.pth file: C:\Program Files (x86)\ArcGIS\Desktop10.0\bin C:\Program Files; (x86)\ArcGIS\Desktop10.0\arcpy; C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Scripts--those paths will then take precedence over the the default search for modules (below the python.exe or pythonw.exe being called).

Finally, since you've uninstalled and installed several versions of Python. At this point, there should be nothing under the C:\Python26 folder except the ArcGIS10.0 folder of the ESRI provided Python 2.6.5 32-bit install. If there is a Lib file there it is a residual of an earlier install and will interfere. It would be a bigger problem if any or your prior Python26 installs were 64-bit.

Also, since you're on 64-bit Windows 7, the Registry path the to 32-bit Python keys are HKLM\SOFTWARE\Wow6432Node\Python If you have a HKLM\SOFTWARE\Python, they would be Keys for a 64-bit install. They also would interfere with the 32-bit install.

share|improve this answer
Hi Stuart. Thanks for the info. I've replied over on, cheers Sam – SamFranklin Feb 28 '11 at 9:07

This is what I did, the Path and PYTHONPATH Environment variables

this is enough for me.

I've used PyScripter but I've downloaded the 2.7 version, It was necessary to use the PyScripter for python 2.6 to get no error with import arcpy

share|improve this answer

do this

  1. open arcgis application manager
  2. set the license manager

review how many of each license level is available. if you want arcpy to check out a specific license level, you'll want to code like this

import arcview
import arcpy
share|improve this answer
Hi - tried import arcview. Received the following error. However, i could then use arcpy okay? >>> import arcview Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> import arcview File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\", line 18, in <module> gp.setProduct("ArcView") RuntimeError: ERROR 999999: Error executing function. >>> import arcpy >>> I've provided a fully answer on: where I could attach screenshots and provide a fuller answer. – SamFranklin Feb 20 '11 at 10:57

I ran into this problem when setting up scripting in a new environment....I had forgotten to set the license manager server using ArcGIS Administrator. DOH

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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