Is This Content Helpful?
We're glad to know this article was helpful.
The following exception is raised when ArcPy fails to import a python script or IDE.
"Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 568, in <module>
env = GPEnvironments(gp)
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 565, in GPEnvironments
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 521, in __init__
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in _refresh
envset = (set(env for env in self._gp.listEnvironments()))
This issue occurs when ArcGIS Desktop and ArcGIS Server are installed on the same machine but only ArcGIS Server is authorized.
When a module is imported into Python, a list of paths is searched to find the module. This list is defined in the 'sys.path' variable. This 'sys.path' variable contains the location of the script, paths defined in the PYTHONPATH environment variable, and installation dependent default paths. Additionally, adding a path configuration file (.pth) to any of these locations appends additional paths to the 'sys.path' variable. When the module is found it attempts to import it and stops scanning the list of paths.
ArcGIS Desktop and ArcGIS Server lay down separate installs of the ArcPy module in their respective install locations. In addition, ArcGIS Desktop and ArcGIS Server place unique path configuration files (desktop.pth and server.pth) in the Lib\site-packages folder of the install location for Python.
To resolve this error, remove the ArcGIS Desktop path to ArcPy from the sys.path variable. The easiest way to do this is by removing or renaming desktop.pth, the ArcGIS Desktop path configuration file.
By default, when installed with ArcGIS Desktop this would be
In the future, to use ArcPy in Python scripts with an ArcGIS Desktop license, rename this file back to desktop.pth.