Python Path Confusion

11498
13
09-22-2011 04:59 PM
ThomMackey
New Contributor III

Hi all,

Having some issues with Python paths in 10.1.

I'm using a VM someone else at work set up. It's running Win Sever 2008 R2 and it has both ArcGIS Desktop 10.1 and Server 10.1 installed (I'm guessing this is part of the problem). I didn't perform the installation so I don't know the procedure which led to this mess.

There appear to be 3 (!) installs of Python on the system. One in C:\Python27, one in C:\Python27\ArcGIS10.1, and one in C:\Python27\ArcGISx6410.1.

My main issue is in Desktop, I can't use any Python functions, because whenever I try to import arcpy, it can't find numpy. Specifically, typing from the Python command window:

>>> import arcpy Runtime error  File <string>, line 1, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\__init__.py, line 20, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\toolbox.py, line 347, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py, line 22, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\_management.py, line 14, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\_graph.py, line 27, in <module> <type 'exceptions.ImportError'>: No module named numpy

I get the same error pop up as a parameter error on the 1st parameter when opening any of the Python tools in the Spatial Statistics toolbox. I guess this is something to do with the validation calling import arcpy.

numpy is in the C:\Python27\ArcGISx6410.1\lib\site-packages and the C:\Python27\ArcGIS10.1 folders but not C:\Python27\lib\site-packages.

The registry entry HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\InstallPath is set to C:\Python27\ArcGISx6410.1\. HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.7\PythonPath is set to C:\Python27\ArcGISx6410.1\Lib;C:\Python27\ArcGISx6410.1\DLLs;C:\Python27\ArcGISx6410.1\Lib\lib-tk. So everything should be in order there.

However, ArcMap is starting Python from C:\Python27 directly. I get the following from the Python command line in ArcMap:

>>> import sys >>> sys.path [ 'C:\\Windows\\system32\\python27.zip', u'c:\\program files (x86)\\arcgis\\desktop10.1\\arcpy', 'C:\\Python27\\Lib', 'C:\\Python27\\DLLs', 'C:\\Python27\\Lib\\lib-tk', 'c:\\program files (x86)\\arcgis\\desktop10.1\\ArcToolbox\\Toolboxes',  'C:\\Program Files (x86)\\ArcGIS\\Desktop10.1\\bin', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages' ]

(Bonus question: What's the 'C:\\Windows\\system32\\python27.zip' doing there?)

If I start IDLE from the "Python 2.7" folder in the start menu, it can't import numpy either and the path is the same as above. If I start IDLE from the ArcGIS\Python 2.7 folder it can see and import arcpy (and numpy, and matplotlib).

If I enter "Python" at the Windows command prompt I get the C:\Python27 one.

I can think of a few solutions but want to know a) how this would have happened, b) why ArcMap is starting Python from C:\Python27 instead of the Python InstallPath in the registry, and c) if I can get rid of one or two of these extra, confusing Python installs, or if not, ensure that Windows will always look at the same installs when installing modules etc.

Thanks all.

0 Kudos
13 Replies
CoMAGOL_ADMINISTRATOR
Occasional Contributor

Hi,

I had the same problem, it seems with install of ArcGIs 10.4.1, i choose full install, and numpy was notinstalled as part of the process. It looks like a bug in the ArcGis 10.4.1 install

Rudy

0 Kudos
curtvprice
MVP Esteemed Contributor

I have not heard of this problem yet after thousands of enterprise installs in my organization, so I suspect the issue is multiple Pythons. Best solution: Remove all the non-Esri pythons seen in  Add/Remove Programs, repair install of ArcGIS 10.4.1, (and background GP and Pro, if you have them). This should get numpy back in your path.

0 Kudos
MatthewBaker2
Occasional Contributor II

Thousands of ESRI Enterprise installs? Well This is not an ESRI enterprise install... so I'm glad I could be the first(-ish)!

The non-ESRI python install is more valuable to me than the ESRI python, so merging the ESRI install into the non-ESRI install is the best solution for me, and I'm glad someone has figured out a way to do this!

0 Kudos
curtvprice
MVP Esteemed Contributor

Esri's install has always supported a previously installed 2.x python, but to get it to work with Esri software you need to make sure the versions of python, numpy, matplotlib, etc line up with what Esri tools expect. If you choose to use an 'existing' python, Anaconda is a really good option so you can make sure everything is compatible. /blogs/dan_patterson/2016/07/17/anaconda-spyder-and-arcgis-pro?sr=search&searchId=efa9d8a0-5c71-41fd...‌  https://community.esri.com/people/curtvprice/blog/2016/02/18/using-a-user-specific-python-startup-sc...

0 Kudos