+ Reply to Thread
Results 1 to 4 of 4

Thread: Python Path Confusion

  1. #1
    Thom Mackey
    Join Date
    Mar 2011
    Posts
    37
    Points
    4
    Answers Provided
    2


    0

    Default Python Path Confusion

    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:

    Code:
    >>> 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:
    Code:
    >>> 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.

  2. #2
    Sarah Williams
    Join Date
    Jan 2011
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: Python Path Confusion

    I am having the same problem has anyone identified how to solve the problem?

    Sarah

  3. #3
    Jeff Swain

    Join Date
    Nov 2009
    Posts
    749
    Points
    184
    Answers Provided
    21


    0

    Default Re: Python Path Confusion

    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.
    Esri Education Specialist
    Esri Certified ArcGIS Desktop Professional
    Training Services
    Esri Training | ArcGIS Ideas

  4. #4
    Curtis Price

    Join Date
    Oct 2009
    Posts
    1,796
    Points
    874
    Answers Provided
    127


    0

    Default Re: Python Path Confusion

    Quote Originally Posted by ThomM View Post
    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.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts