:: epd32arc.bat :: start EPD32 python prompt with arcpy @echo off set EPDPATH=E:\python27_epd32 set AGSPATH=D:\ArcGIS\Desktop10.1 :: save paths set PATHENV=%PATH% set PPATHENV=%PYTHONPATH% :: set paths EPD with access to arcpy set PATH=%EPDPATH%;%EPDPATH%\scripts;%PATH% set PYTHONPATH=%PYTHONPATH%;%AGSPATH%\bin;%AGSPATH%\arcpy;%AGSPATH%\ArcToolbox\Scripts cmd /c %EPDPATH%\python.exe :: restore paths set PATH=%PATHENV% set PYTHONPATH=%PPATHENV% :: delete variables set EPDPATH= set AGSPATH= set PATHENV= set PPATHENV=
:: arcmap_epd.bat - start ArcMap with EPD32 libraries available @echo off :: set the paths below to your install locations set EPDPATH=E:\python27_epd32 set AGSPATH=D:\ArcGIS\Desktop10.1 :: save paths set PATHENV=%PATH% set PPATHENV=%PYTHONPATH% :: set paths for ArcMap w/ EPD set PATH=%EPDPATH%;%EPDPATH%\scripts;%PATH% set PYTHONPATH=%PYTHONPATH%;%EPDPATH%\lib\site-packages echo Starting ArcMap w/ Enthought Python Distribution modules... start /b /d %AGSPATH%\bin ArcMap.exe :: restore paths set PATH=%PATHENV% set PYTHONPATH=%PPATHENV% :: delete variables set EPDPATH= set AGSPATH= set PATHENV= set PPATHENV=
# .pth file for arcpy C:\ArcGIS\Desktop10.1\bin C:\ArcGIS\Desktop10.1\arcpy C:\ArcGIS\Desktop10.1\ArcToolbox\Scripts
# .pth file for EPD Canopy C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\Lib\site-packages C:\Users\rsignell\AppData\Local\Enthought\Canopy32\System\Lib\site-packages
import sys k = 0 for p in sys.path: print "{0:4} {1}".format(k,p) k += 1
>>> k = 0
>>> for p in sys.path:
... print "{0:4} {1}".format(k,p)
... k += 1
...
0 (os.curdir - current python working folder)
1 C:\ArcGIS\Desktop10.1\ArcToolbox\Toolboxes\USGS_EGISTools\scripts
2 C:\Windows\system32\python27.zip
3 C:\Python27\ArcGIS10.1\DLLs
4 C:\Python27\ArcGIS10.1\lib
5 C:\Python27\ArcGIS10.1\lib\plat-win
6 C:\Python27\ArcGIS10.1\lib\lib-tk
7 C:\Python27\ArcGIS10.1
8 C:\Python27\ArcGIS10.1\lib\site-packages
9 C:\ArcGIS\Desktop10.1\bin
10 C:\ArcGIS\Desktop10.1\arcpy
11 C:\ArcGIS\Desktop10.1\ArcToolbox\Scripts
>>> import arcpy
>>> arcpy.__file__
'C:\\ArcGIS\\Desktop10.1\\arcpy\\arcpy\\__init__.py'
Curtis, thanks for your help with this. I'm still experiencing the same error as others in this thread (ImportError: DLL load failed: %1 is not a valid Win32 application) after adding the arcpy.pth files to the Canopy site packages directory as instructed above. I dumped out the sys.path (copied below), and as you can see, there are Canopy paths both before and after the ArcGIS paths. Do you know how to get the Canopy paths to load after the ArcGIS paths, as you suggested?
0 C:\Users\scott.stephenson\Dropbox\Python\scripts\Emissions 1 2 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\Scripts\python27.zip 3 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\DLLs 4 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib 5 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\plat-win 6 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\lib-tk 7 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64 8 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User 9 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\lib\site-packages 10 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\lib\site-packages\PIL 11 C:\Program Files (x86)\ArcGIS\Desktop10.2\bin 12 C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy 13 C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts 14 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\lib\site-packages\win32 15 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\lib\site-packages\win32\lib 16 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\User\lib\site-packages\Pythonwin 17 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata 18 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\site-packages 19 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\site-packages\win32 20 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\site-packages\win32\lib 21 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\site-packages\Pythonwin 22 C:\Users\scott.stephenson\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.5.5.3123.win-x86_64\lib\site-packages\IPython\extensions 23 C:\Users\scott.stephenson\.ipython
Did you:
1) make sure the canopy path is not in the system PATH (this is included in the python sys.path)
2) name the canopy .pth file in /lib/site-packages starting with zz so it is loaded last.
I have moved on to using anaconda (free) but this approach is still working for me. I use an environment set up specifically compatible with ArcGIS ("arc1022") and then I can also have other environments to work with non-ArcGIS compatible packages.
Thanks again Curtis. I don't know how to check if the canopy path is not in the system PATH. I named the .pth files (both zzarcpy.pth in the Canopy site-packages folder, and zzcanopy.pth in the Python27 site-packages folder) accordingly so they would be loaded last. No luck
I've also tried installing and running the 32-bit version of Canopy -- no luck there either.
Would you recommend I try using Anaconda? If it's easier to get arcpy to load in Anaconda, I will gladly give that a try.
Go with what works without problems or special considerations... people can weigh in if they have information to the contrary
I have both versions installed for: (associated modules in brackets)
Amazingly, if you let Arcmap and ArcGIS Pro install the version of python etc FIRST, PythonWin and PyScripter find them and their appropriate version without any floor dancing about paths etc.
So unless you have a mission critical reason to use something else, you might use the current known-to-work IDE's and wait until IronPython comes along (or so is rumoured)
Back to you Curtis for counter-point