Select to view content in your preferred language

Using Enthought Canopy with ArcGIS/ArcPy

7595
15
04-22-2013 09:30 AM
JordanWeaver
New Contributor
What is the best method for developing Python scripts for ArcGIS in a third-party installation of Python and IDE? I have tried using the suggested workflow from ESRI... that being the included installation of Python and PythonWin for the IDE. Unfortunately, these will not be sufficient or enjoyable so I was hoping to use the Canopy (formerly EPD) IDE (utilizing PyLab, etc.) for development with access to those elements that are available in the ArcGIS "preferred" environment.

I'm sure there are multiple steps to accomplishing this, and one problem may be that I have the 64-bit installation of Canopy (which I can uninstall and install the 32-bit version if necessary), but I was wondering if anyone has attempted to tackle this. I didn't want to start experimenting with environment variables until I was sure that I had the appropriate installations, as well as an understanding of what I was trying to accomplish.

Thanks in advance for any help with this problem.

Setup:
Windows 7
ArcGIS Desktop 10.1
Enthought Canopy (Python 2.7.3 64-bit)

I apologize if this has been answered previously, but I couldn't find an existing good explanation on the forum. Please redirect if solution already exists.
Tags (2)
0 Kudos
15 Replies
curtvprice
MVP Esteemed Contributor

> I don't know how to check if the canopy path is not in the system PATH.

The system path is PATH environment variable in Windows. Search for "env" in the windows search and pick user environment variables to get the dialog in WIn7.

> Would you recommend I try using Anaconda?

I've had really good luck with Anaconda, mostly because you can install it without modifying the main system Pythons that Arc is using. Anaconda environments are just the ticket for creating an arc compatible setup and it makes it really easy to install versions of things that will be compatible with the ArcGIS stack.

Dan is right you really need to "clean house" --

1) remove all pythons you see in add/remove programs

2) Repair Desktop and/or Pro (this will restore Windows python paths, etc. This should get ArcMap seeing what it needs to see again.

3) IF YOU REALLY NEED IT - Install other Pythons, i.e. Anaconda, EPD whatever  (use the option to NOT modify the Windows Python setups when installing Anaconda)!

0 Kudos
ScottStephenson1
Deactivated User

Curtis, I deleted Canopy from the system PATH, and it worked perfectly. Truthfully, I don't know why it worked, but thank you! I may move toward Anaconda in the future, but for now, Canopy seems to be working.

Dan and Curtis, thanks for the advice. I will keep this in mind next time I need to "clean house" and remove redundant and/or incompatible Python versions.

FranciscoGoerlich
Emerging Contributor
Using the pth files I get the following error when importing ArcPy:
import arcpy:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-50d283eebbb3> in <module>()
----> 1 import arcpy

C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\__init__.py in <module>()
     19 import warnings
     20
---> 21 from arcpy.geoprocessing import gp
     22 from arcpy.geoprocessing import env
     23 from arcpy.geoprocessing._base import gptooldoc as _gptooldoc

C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\__init__.py in <module>()
     12 #
     13 #email: contracts@esri.com
---> 14 from _base import *

C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py in <module>()
     12 #
     13 #email: contracts@esri.com
---> 14 import arcgisscripting
     15 import functools
     16

ImportError: DLL load failed: %1 no es una aplicación Win32 válida.

Presumibly because EDP-Canopy is 64 bits and ArcGIS is 32.
Should I unistall EDP-Canopy 64 bits, and install the 32-bits version, or it is enought that I install ArcGIS for Desktop Background GP (64-bit) on the top of the standar version of ArcGIS?

Thanks,
0 Kudos
curtvprice
MVP Esteemed Contributor
You may install 32 bit AND 64 bit canopy. Your .pth files in the Python27\ArcGIS10.2 and Python27\ArcGISx6410.2 would then point to 32 and 64 bit canopy, 32->32 and 64->64.

Canopy does some magic with virtual environments that I haven't quite worked out yet in terms of how it works with ArcGIS - but this should be quite doable.
0 Kudos
FranciscoGoerlich
Emerging Contributor
Thanka a lot.
I have now installed ArcGIS 10.2 Background GP (64-bit) and can import arcpy from Canopy without problems.
However when I try to run a ToolBox from ArcGIS 10.2 that uses py, then I get an error:

Executing: GenerateSpatialWeightsMatrix D:\GIS\CNIG\Equipamiento_Geográfico_Referencia_Nacional\lineas_limite_2011Mayo\Municipios2006_ETRS89.shp INENumMuni D:\GIS\CNIG\Equipamiento_Geográfico_Referencia_Nacional\lineas_limite_2011Mayo\Municipios2006_ETRS89.swm CONTIGUITY_EDGES_CORNERS EUCLIDEAN 1 # 0 NO_STANDARDIZATION # # # #
Start Time: Fri Mar 28 20:39:43 2014
Running script GenerateSpatialWeightsMatrix...
Constructing spatial weights based on polygon contiguity (Edges or Corners)....
WARNING 000916: The input feature class does not appear to contain projected data.

Traceback (most recent call last):
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 910, in <module>
    setupWeights()
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 110, in setupWeights
    contiguityType = "QUEEN")
  File "c:\program files (x86)\arcgis\desktop10.2\ArcToolbox\Scripts\Weights.py", line 201, in polygon2SWM
    numNeighs = kNeighs)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts\WeightsUtilities.py", line 203, in __init__
    self.setHeader()
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts\WeightsUtilities.py", line 261, in setHeader
    header = NUM.array([header], '<c')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 0: ordinal not in range(128)

Failed to execute (GenerateSpatialWeightsMatrix).

I get the same error using forefront or background processing.

It seems that ArcGIS does not access Canopy. I have only installed the 64 version of Canopy.

Thanks a lot in advance.
0 Kudos
ShaunWalbridge
Esri Regular Contributor
Francisco, I don't think this is due to your Python installation, but a bug in the particular function you're using. I suggest one option to fix it in the other thread posted.
0 Kudos