import arcpy not working in PythonWin

7422
7
01-02-2014 07:05 AM
GeospatialTechnology
Occasional Contributor
Hello,

I'm trying to learn to Python but am stumbling at the first block.

When I try to import arcpy I get the following error message:

>>> import arcpy
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named arcpy


I'm sure I've imported and installed everything as I should. Any ideas?

I've also tried running it in the Python window in ArcGIS. I get the following error message. I was trying to alter some code before christmas so I'm not sure if I've accidently deleted something.

Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 24, in <module>
    from arcpy.toolbox import *
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\toolbox.py", line 351, in <module>
    from management import Graph, GraphTemplate
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 22, in <module>
    import _management
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\_management.py", line 14, in <module>
    import _graph
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\_graph.py", line 27, in <module>
    import numpy
ImportError: No module named numpy
Tags (2)
0 Kudos
7 Replies
ChrisSnyder
Regular Contributor III
Perhaps you installed another version of Python other than the one that is (by default) installed with ArcGIS? BTW: Do not do that.

Although it seems drastic, my recommendation is to uninstall anything and everything ArcGIS and Python related, and reinstall ArcGIS... which as I said auto installs/configures the coorect vbersion of Python. Then if you want, install the appropriate version of PythonWin. For v10.2, I believe that would be the 'pywin32-218.win32-py2.7.exe' file available here: http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
0 Kudos
GeospatialTechnology
Occasional Contributor
Perhaps you installed another version of Python other than the one that is (by default) installed with ArcGIS? BTW: Do not do that.


Too late! That explains why it's broken. I've been messing around with Python trying to get some script to work that I copied from somewhere. I downloaded and installed a few different version of Python. Looks like a complete resinstall is in order :S
0 Kudos
ZachLiu1
Occasional Contributor II
If you installed another python, try to copy the file "C:\Python27\ArcGIS10.1\Lib\site-packages\Desktop10.1.pth" to your other python installation path like "C:\Python27\Lib\site-packages".
0 Kudos
GeospatialTechnology
Occasional Contributor
Thanks Zackliu. I've got arcpy working again now in ArcGIS at least. I uninstalled all previous versions of python and reinstalled python from the ArcGIS installation package.

However now PythonWin won't install. When I try i get a message saying Python 2.7 is not present even though I just installed with with ArcGIS. I'm not sure where to go from here. Like csny mentioned I think I might just go for a complete uninstall and reinstall.
0 Kudos
ChrisSnyder
Regular Contributor III
I think I might just go for a complete uninstall and reinstall


I know it seems drastic, but just think of all the time it would have saved if you had just done this in the 1st place!

... I speak from experience :rolleyes:
0 Kudos
HåvardMoe
New Contributor III
However now PythonWin won't install. When I try i get a message saying Python 2.7 is not present even though I just installed with with ArcGIS.

For some reason, the Python installed with ArcGIS isn't properly recogniced by other installers. I think there might be some register settings that aren't properly set...  I've had the same issue when trying to run installers that required python pre-installed.

(Haven't solved this myself, as I installed python on a different PC to test the module I was trying to install instead)
0 Kudos
StacyRendall1
Occasional Contributor III
I think you need to add it to your system path, check this post for more info:

http://pythongisandstuff.wordpress.com/2013/07/10/locating-python-adding-to-path-and-accessing-arcpy...

Also ff, when attempting to install an additional library to Python, you receive an error stating that the correct Python version is not found in the registry:


  • Download the package source (usually a .zip file, not specific to any Python version)

  • Unzip the package

  • Open a command prompt within the package folder and run:

  • python setup.py install

  • where python is the Python you want to install the library to. If it is not on the path (either temporarily or permanently) you must supply the full path to it.

0 Kudos