Can´t import Arcpy on ArcGIS 10.2

602
5
Jump to solution
01-27-2014 04:33 AM
BirteHegemann
New Contributor
Hi.
I simply don´t get Arcpy to import! Command line import arcpy produdes this Traceback:

  File "C:/Daten/Untersuchungsgebiete/test.py", line 1, in <module>
    import arcpy
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py", line 21, in <module>
    from arcpy.geoprocessing import gp
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 592, in <module>
    env = GPEnvironments(gp)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 589, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 545, in __init__
    self._refresh()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 547, in _refresh
    envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized

Any ideas to fix the problem?
Regards
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MichaelVolz
Esteemed Contributor
I guess it depends how you are running the python script.

I personally like to use IDLE when testing my scripts.  In order to get the python scripts to run as 32-bit in this environment, I had to add a shortcut to pythonw.exe residing at C:\Python27\ArcGIS10.2 to my Windows SendTo menu at C:\Users\"Windows User Name"\AppData\Roaming\Microsoft\Windows\SendTo.

I then right click on a .py file and navigate to SendTo and it allows me to pick this shortcut.  When you run the script, it should tell you the mode it is running in at the top.

View solution in original post

0 Kudos
5 Replies
MichaelVolz
Esteemed Contributor
Can you tell whether your script is using the 32-bit or 64-bit python version?
0 Kudos
BirteHegemann
New Contributor
Its 64bit!
0 Kudos
MichaelVolz
Esteemed Contributor
You'll need to run the python script with the 32-bit version.  I have Windows 2008 Servers that are 64-bit with both ArcGIS Desktop and ArcGIS Server software installed.  I tried running python scripts after the install, but it was throwing the same types of errors.  I then checked and saw it was using the 64-bit version of python.  Once I made the script use 32-bit python it worked.
0 Kudos
BirteHegemann
New Contributor
Sorry but how do I make it use 32-bit python?
0 Kudos
MichaelVolz
Esteemed Contributor
I guess it depends how you are running the python script.

I personally like to use IDLE when testing my scripts.  In order to get the python scripts to run as 32-bit in this environment, I had to add a shortcut to pythonw.exe residing at C:\Python27\ArcGIS10.2 to my Windows SendTo menu at C:\Users\"Windows User Name"\AppData\Roaming\Microsoft\Windows\SendTo.

I then right click on a .py file and navigate to SendTo and it allows me to pick this shortcut.  When you run the script, it should tell you the mode it is running in at the top.
0 Kudos