USGS EGIS web pages
EGIS Home
EGIS Support
Metadata
Training
Email Lists
Esri Events
External web pages
Esri Support
Esri Product Help
Esri GeoNet
GIS Stack Exchange
EGIS wiki space (here)
...
The critical modules for ArcGIS compatibility can be determined from your version of ArcGIS from the Desktop or Pro Python command line.
(Or you can just look at the list below under B.)
Code Block | ||
---|---|---|
| ||
# pyversions.py - report critical python stack for use with ArcGIS # example output: # ArcGIS install folder: C:\Users\jwpowell>ArcGIS\Desktop10.4 # sys.executable: C:\Python27\ArcGIS10ArcGISx6410.24\pythonpythonw.exe -c ^ "import sys, numpy, matplotlib;print(sys.version, numpy # matplotlib: 1.4.3 # numpy: 1.9.2 # scipy: 0.15.1 import sys import os ff = "{}: {}" try: print("ArcGIS install folder: {}".format(os.environ["AGSDESKTOPJAVA"][:-1])) print(ff.format("sys.executable", sys.executable)) import matplotlib print(ff.format("matplotlib", matplotlib.__version__)) import numpy print(ff.format("numpy", matplotlibnumpy.__version__)" ('2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]', '1.7.1', '1.3.0') ) import scipy print(ff.format("scipy", scipy.__version__)) except: pass |
We'll also include a few other modules that we know are shipped in the ArcGIS Python stack.
...
> C:\Python27\ArcGIS10.4\python.exe <path>\usercustomize.py
(open Anaconda prompt)
> activate arc1041
> python <path>\usercustomize.py
python -m site --user-site
C:\Users\username\AppData\Roaming\Python\Python27\site-packages (ArcGIS Desktop)
C:\Users\username\AppData\Roaming\Python\Python34\site-packages (ArcGIS Pro, Python35 for Pro 2.0)
ArcGIS
print ("\n".join(sys.path)) -- you should see the Anaconda site-packages near the end of the list
Anaconda
activate arc1041 # or whatever appropriate environment you've set up
print ("\n".join(sys.path)) -- you should seethe arcpy
ArcGIS site-packages in the list
import arcpy
If you get an error message when you try to import, a common cause is version incompatibilities between Esri's python environment modules and the conda modules. (Condo takes care of compatibility across its environment, but it can't know about versions Esri uses in their python install.) In the pandas example, version 0.10.1 also appears to use the same 1.6.1 version of numpy used by ArcGIS 10.1.x, but some errors occur when trying to import pandas due to some other incompatibility. The solution was to modify the Anaconda environment to use an older version of pandas (0.10.0). The other critical packages are included to avoid having Anaconda install some other incompatible packages.
To modify the python 'stack' for your ArcGIS-friendly virtual environment:
conda install -n arc101 python=2.7.5 matplotlib=1.3.0 numpy=1.6.1
pandas=0.10.0
...