Saturday 20 January 2018

arcgis 10.1 - How to access Esri ArcPy modules from Enthought Canopy?


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?



Answer



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!


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...