Python Path Confusion

Discussion created by tmackey-esriaustralia-com-au-esridist on Sep 22, 2011
Latest reply on Oct 10, 2016 by curtvprice

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\, line 20, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\, line 347, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\, line 22, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\, line 14, in <module> File c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\, 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\\', 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\\' 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.