Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have ArcGIS 10.1 running on my windows system and I have also installed the new 32-bit Canopy Express Enthought Python Distribution.

Is it possible to load and use the Esri ArcPy modules from Canopy?

share|improve this question
add comment

2 Answers

up vote 11 down vote accepted

There is an easy way that doesn't involve messing with your system PATH or PYTHONPATH.

The Enthought Python Distributions, including Canopy x32, are stand-alone and don't need anything in the registry or in the environment variables. So they can play nice with other Python distributions like the one that comes with ArcGIS 10.1.

To access ArcGIS 10.1 python modules from Enthought Canopy: Create a "path" file in the Canopy user directory that points to the ArcGIS 10.1 python modules. On my system, I created a text file called arcpy.pth with these 4 lines:

# .pth file for arcpy
C:\ArcGIS\Desktop10.1\bin
C:\ArcGIS\Desktop10.1\arcpy
C:\ArcGIS\Desktop10.1\ArcToolbox\Scripts

and put arcpy.pth in the Canopy User site-packages directory:

C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages

To access Enthought Canopy modules from ArcGIS 10.1: Create a "path" file in the Arc site-packages folder that points to the Canopy python modules. On my system, I created a text file called epd.pth with these 3 lines:

# .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

and then put epd.pth in the Arc site-package folder:

C:\Python27\ArcGIS10.1\Lib\site-packages

That's all I needed to do!

-Rich

P.S. This works because Enthought Canopy 1.0 and ArcGIS10.1 are at the same version of Python (2.7) and Numpy (1.6.1). I hope we can continue to have this compatibility!

Update: I just tried this with Canopy 1.0.3, which uses Numpy 1.7.1, and it still works, even though ArcGIS 10.1 is at Numpy 1.6.1. Hurray! Yippee!

share|improve this answer
1  
A few notes: 1. Make sure you have installed EPD/Canopy x32 for use with ArCGIS Desktop. 2. pth files are loaded in alphabetical order, so to avoid conflicts I have named these files: "zzArcGIS.pth" (Canopy site-packages folder) and "zzEPD.pth" (ArcGIS site-packages folder). 3. If you are using ArcGIS Desktop x64 Background GP, or ArcGIS Server (which uses Python x64) you need to install 64-bit EPD/Canopy and add .pth files pointing to the 64-bit EPD and ArcGIS Python site-packages folders. –  Curtis Price Apr 25 '13 at 19:10
    
Excellent points Curtis. Thanks! –  Rich Signell Apr 26 '13 at 13:13
    
+1 for nice detail –  D.E.Wright Jul 1 '13 at 18:13
add comment

Yes, it is. Here is an excerpt from an internal install guide that was just used to do the same on my machine (please make sure these apply to your particular machine):


Configure environment for EPD

  1. Add a new PATH in your user variables (prepend the epd to the PATH):

    (edit the paths below according to the version of EPD or ArcGIS you are using) PATH=C:\Python27_epd32;C:\Python27_epd32\Scripts;%PATH%

  2. If ArcGIS is installed, set the PYTHONPATH environment variable so
    ArcGIS can import EPD modules, and EPD can import ArcPy:

    PYTHONPATH= C:\Python27_epd32\lib\site-packages; C:\ArcGIS\Desktop10.1\bin; C:\ArcGIS\Desktop10.1\arcpy; C:\ArcGIS\Desktop10.1\ArcToolbox\Scripts

If you run into problems with ArcGIS conflicting with EPD, you can easily remove EPD from the ArcGIS environment by removing the references to EPD in the PYTHONPATH.


Disclaimer! While the steps below have worked for me in the past, I'm not a very DOS-savvy person and I'd feel better if you consulted someone in your IT department to make sure I'm not handing out poor advice. With that said, read on...

Adding paths to your environment variables is fairly straightforward using the DOS command prompt (All Programs > Accessories > Command Prompt). You will use the command setx to permanently alter your PATH and PYTHONPATH environment variables.

At the command prompt, type "echo %PATH%"; it will print out the string that is the PATH variable. It's essentially just a long string of characters. Now try it with the PYTHONPATH variable to see what's in that one. You'll notice each path in those variables is separated by a semi-colon (;). When we add new paths to these variables we must include these.

enter image description here

Essentially what you will be doing is telling the computer you want your new PATH and PYTHONPATH variables to equal some new string (path(s)) (like C:\Python27_epd32\lib\site-packages;C:\ArcGIS\Desktop10.1\bin;) plus what's already stored in the variable.

The command you will execute to set your PATH variable is: setx PATH=C:\Python27_epd32;C:\Python27_epd32\Scripts;%PATH% (make sure these paths are applicable to your system)

enter image description here

The command you will execute to set your PYTHONPATH variable is: setx PYTHONPATH=C:\Python27_epd32\lib\site-packages;C:\ArcGIS\Desktop10.1\bin;C:\ArcGIS\Desktop10.1\arcpy;C:\ArcGIS\Desktop10.1\ArcToolbox\Scripts;%PYTHONPATH% (make sure these paths are applicable to your system)

NOTE: Make sure that you add "%PATH%" and "%PYTHONPATH%" to the end of the respective commands. If you don't, you will be overwriting those variables with only the new paths and you will lose the current contents.

share|improve this answer
    
Thanks, Jason! However, I need a little more detail on how to do this - how do I edit user variables? –  SharonB Apr 24 '13 at 13:22
    
At the DOS command prompt you'll want to use the SETX command (2nd answer at stackoverflow.com/questions/8358265/…) to permanently prepend the paths to your PATH and PYTHONPATH variables. You can also do this via some of the Administrative Tools if I remember correctly, but I don't have permissions on my work computer to use them so I usually use a DOS window. –  Jason Apr 24 '13 at 14:58
    
Thank you again...as a novice Python-er who works primarily in IDLE (never touched the DOS command prompt) I don't know about/how to add the new PATH and PYTHONPATH environment variables. Perhaps screenshots and/or an option to do this through a GUI (not DOS)? –  SharonB Apr 24 '13 at 18:03
    
Whoa. Thank you. This is impressive. Very much appreciated, I'll let you know how it goes. –  SharonB Apr 24 '13 at 19:41
    
Hehe, it's a simple process, but looks complicated because of all of the paths! I hope all of your work is coming together! –  Jason Apr 24 '13 at 19:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.