3 Replies Latest reply on Oct 15, 2012 3:34 PM by curtvprice

    Python Path Confusion

    tmackey-esriaustralia-com-au-esridist
      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.
        • Re: Python Path Confusion
          sw2279
          I am having the same problem has anyone identified how to solve the problem?

          Sarah
          • Re: Python Path Confusion
            JSwain-esristaff
            Sarah,

            I am glad to see that the recommendation to uninstall the other version of python and then repair ArcMap worked to get the process working again.  Thanks for calling Esri Support.
            • Re: Python Path Confusion
              curtvprice

              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.


              The Python27/ArcGIS10.1 installed with Desktop, the Python27/ArcGISx6410.1 is installed with ArcGIS Server. I don't know how the third one got installed. I'm guessing last, because Windows is clearly set up to have that Python in the path.

              Sounds to me like the best approach is to uninstall the python installed in C:\Python27. Then do a repair install of Desktop and Workstation (from add/remove programs).


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


              This is a deprecated path from the early days of Python before the current setup (startup scripts, PYTHONPATH, site-packages) was implemented for startup.. You can safely ignore it.