AnsweredAssumed Answered

sys.path in ArcGIS python implementation (standalone - and in ArcGIS Desktop prompt)

Question asked by curtvprice Champion on Sep 24, 2012
Latest reply on Sep 24, 2012 by curtvprice
ArcGIS 10.1 Final
Separate Python distribution (EPD) installed in its own folder (not in system PATH).

Here's what I see from a command line:


Z:\>d:\python27\ArcGIS10.1\python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print '\n'.join(sys.path)
  ("" - current folder)
D:\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\USGS_EGISTools\scripts # in my PYTHONPATH
C:\WINDOWS\system32\python27.zip
d:\python27\ArcGIS10.1\DLLs
d:\python27\ArcGIS10.1\lib
d:\python27\ArcGIS10.1\lib\plat-win
d:\python27\ArcGIS10.1\lib\lib-tk
d:\python27\ArcGIS10.1
d:\python27\ArcGIS10.1\lib\site-packages
D:\ArcGIS\Desktop10.1\bin       # Desktop10.1.pth in site-packages
D:\ArcGIS\Desktop10.1\arcpy   # Desktop10.1.pth in site-packages
D:\ArcGIS\Desktop10.1\ArcToolbox\Scripts # Desktop10.1.pth in site-packages
>>>


But from within the ArcMap Python prompt I'm seeing paths that are not in my PYTHONPATH, somehow it's picking up libraries from my EPD.


>>> print '\n'.join(sys.path)
D:\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\USGS_EGISTools\scripts # in my PYTHONPATH
d:\arcgis\desktop10.1\arcpy
C:\WINDOWS\system32\python27.zip
E:\python27_epd32\Lib   # where did these three come from??
E:\python27_epd32\DLLs
E:\python27_epd32\Lib\lib-tk
D:\Python27\ArcGIS10.1\Lib
D:\Python27\ArcGIS10.1\DLLs
D:\Python27\ArcGIS10.1\Lib\lib-tk
C:\Documents and Settings\cprice # where did this come from?
D:\ArcGIS\Desktop10.1\bin # Desktop10.1.pth in site-packages (why  here?)
D:\Python27\ArcGIS10.1
D:\Python27\ArcGIS10.1\lib\site-packages
D:\ArcGIS\Desktop10.1\arcpy # Desktop10.1.pth in site-packages
D:\ArcGIS\Desktop10.1\ArcToolbox\Scripts # Desktop10.1.pth in site-packages


My EPD install gives me a shorter list, but it's still mysterious to me:


Z:\>e:\python27_epd32\python.exe
Enthought Python Distribution -- www.enthought.com
Version: 7.3-2 (32-bit)

Python 2.7.3 |EPD 7.3-2 (32-bit)| (default, Apr 12 2012, 14:30:37) [MSC v
Type "credits", "demo" or "enthought" for more information.
>>> import sys
>>> print "\n".join(sys.path)
  ("" - current folder)
D:\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\USGS_EGISTools\scripts
e:\python27_epd32\python27.zip
e:\python27_epd32\DLLs
e:\python27_epd32\lib
e:\python27_epd32\lib\plat-win
e:\python27_epd32\lib\lib-tk
e:\python27_epd32
e:\python27_epd32\lib\site-packages
e:\python27_epd32\lib\site-packages\PIL   # PIL.pth in site-packages
e:\python27_epd32\lib\site-packages\win32 # pywin32.pth in site-packages
e:\python27_epd32\lib\site-packages\win32\lib # pywin32.pth in site-packages
e:\python27_epd32\lib\site-packages\Pythonwin # pywin32.pth in site-packages

This leaves me with some question about the ArcGIS Desktop Python prompt.

1. There are some entries in the sys.path in both setups that I honestly don't see where they came from. The first one in the lists above came from my PYTHONPATH, and the the last three are in the .pth file in site-packages. Where did all the others entries come from?
2. There are some imports (sys, arcpy) that the ArcMap python window has loaded already. Where did that happen?
3. The ArcMap python prompt is picking up some paths from somewhere mysterious (in italic above)
4. In all setups, what's up with the path: C:\WINDOWS\system32\python27.zip. That file does not exist in my install.

Outcomes