Confluence Retirement

In an effort to consolidate USGS hosted Wikis, myUSGS’ Confluence service is scheduled for retirement on January 27th, 2023. The official USGS Wiki and collaboration space is now SharePoint. Please migrate existing spaces and content to the SharePoint platform and remove it from Confluence at your earliest convenience. If you need any additional information or have any concerns about this change, please contact Thank you for your prompt attention to this matter.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 24 Next »

The challenge here is getting the ESRI-provided version of Python and associated module s to work with non-ESRI provided modules that you gain via Anaconda. Generally speaking, when you download and install Anaconda, you will get newer versions of Python-related material (including standard modules like numpy) than what is in your ArcGIS "Python Stack," which will not work. You therefore must configure Anaconda to be compatible with the version of ArcGIS "Python stack" (10.1, 10.2, 10.3, Pro) that you have installed.  The instructions here describe how to install older versions of modules into Anaconda that will work with ArcGIS. 



What is the Anaconda distribution?

Anaconda is an open-source Python distribution that makes is possible to easily install many pre-packaged third party Python modules. It is a competing alternative to the Enthought Python Distribution (EPD).

It has some big advantages over using Esri's distributions:

  • Very useful add-ons not in Esri's standard distribution are available (iPython, pandas, etc).
  • You can install and update Python as a regular user
  • You can install and remove, and update third party packages easily (and without admin access)
  • A single Python install stack can be used to set up different "virtual environments" (including "ArcGIS-standard" ones)


The general workflow to make this happen is to:

  • Install Anaconda without fouling the Windows environment (paths, registry) to break Esri's python stack
  • Configure Anaconda with the particular add-ons you want, and
  • Configure ArcGIS's Python so that it is aware of the appropriate Anaconda content.

1) Install Anaconda (Single-User - no admin access needed)

  1. Go to
  2. Download the 32-bit (x86) version of Anaconda (ArcMap [32-bit] can only directly work with 32-bit Python)
  3. In the install dialogs:
    1. Select install for a single user (Not "All Users")
    2. Install to a folder where there is going to be plenty of space (recommend the D drive, not the C drive)
    3. IMPORTANT: To avoid breaking ArcGIS, uncheck the checkboxes  (a) make Anaconda the default Python and (b) add Anaconda's Python to the PATH. 
    4. Here are screenshots to help guide you through the install process.

At this point, you will have full Anaconda version of the python environment that's spiffy and new and totally useless with ArcMap. 

2) Configure Anaconda

The following workflow will demonstrate how set up an Anaconda virtual environment similar to ArcGIS, with the "pandas" module added. Pandas is great for a whole variety of data processing tasks (just google "python pandas"). If you get this far, you can adapt this workflow to include other modules you may want.

The following example is for ArcGIS 10.2.2.

A. Find the versions of numpy and matplotlib Arc is using.

Open ArcMap and its Python window, and enter these commands:

>>> import sys, numpy, matplotlib
>>> print(sys.version, numpy.__version__, matplotlib.__version__)
'2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]', '1.7.1', '1.3.0')

B. Create an Anaconda virtual environment (including pandas) that is compatible with ArcGIS 10.2.2.

Rather than modifying the basic Anaconda installation, you can create a custom environment within Anaconda and specify the version of Pandas you want there. To do this:

  1. Get to the Anaconda Command Prompt (Start > Search > Anaconda, pick "Anaconda Command Prompt")
  2. Type "conda create -n arc1022 python=2.7.5 numpy=1.7.1 matplotlib=1.3.0 xlrd=0.9.2 xlwt=0.7.5 pyparsing=1.5 pandas"
    or, better yet, use this file (conda_arc1022.txt) that has a more complete list
    "conda create --file conda_arc1022.txt" 
  3. Anaconda's conda command will then:
  • Determine that the specified versions are compatible
  • Find most recent compatible versions of packages not completely specified 
  • Prompts you to continue
  • Downloads (only) the pieces you need to "overlay" with the base environment to get the environment you have specified.
  • Set up a subdirectory in the Anaconda install folder "arc1022" and downloads these packages into it.

C. Test the virtual environment

D:\Users\cprice>activate arc1022
Activating environment "arc1022"...
[arc1022] D:\Users\cprice>conda list
# packages in environment at D:\Users\cprice\Anaconda\envs\arc1022:
dateutil 2.4.1 py27_0
matplotlib 1.3.0
np17py27_0numpy 1.7.1 py27_3
pandas 0.13.0 np17py27_0
[arc1022] D:\Users\cprice>python
Python 2.7.5 |Continuum Analytics, Inc.| (default, Jul 1 2013, 12:41:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

D. More packages

You can add more packages using conda install, but make sure you specify dependencies so you won't change your python or numpy versions. For example, if we didn't add pandas in the beginning, we could add it using this command. Specifying python and numpy versions makes sure we get a compatible version that won't break arcpy/ArcGIS.

conda install -n arc1022 python=2.7.5 numpy=1.7.1 pandas

You're not limited to what conda has, now that you have a virtual environment you can use it to install packages that are not available through conda install. However, it's up to you to make sure the package you install is compatible with your environment. Here's an example on how to install a commonly desired GIS-re-ated module (shapely) into a conda virtual environment using the python pip utility:

3) Configure the conda environment to access ArcGIS

Copy the .pth file to your Anaconda environments site-packages folder so Anaconda can "see" arcpy

[arc1022] D:\Users\cprice> copy c:\Python27\ArcGIS10.2\lib\site-packages\desktop10.2.pth ^
[arc1022] D:\Users\cprice>python
Python 2.7.5 |Continuum Analytics, Inc.| (default, Jul 1 2013, 12:41:55) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
>>> import pandas

4) Configure ArcGIS to find conda packages

  1. If you have admin access:

    1. Navigate to "C:\Python27\ArcGIS10.2\Lib\site-packages"

  2. If you don't
    1. Run this command: C:\Python27\ArcGIS10.2\python.exe -m site --user-site
    2. Navigate to the reported path (you may have to create the folder)
  3. Create and edit an ASCII file called "conda.pth" This file will have a single line, containing the path to the environment site-packages folder:
    For example: D:\users\cprice\Anaconda\envs\arc1022\lib\site-packages
  4. You should now be able to import pandas (and any other third-party packages you have loaded to Anaconda) from the ArcMap command prompt and it will also be available to script tools.
  5. In ArcMap and other Esri desktop applications, make sure your script that requires Anaconda modules will not run in the x64 background Python. There are several approaches to doing this:
    1. Go to Geoprocessing > Options and disable all background processing. 
    2. When setting up your script that uses Anaconda, check the box to force the tool to always run in the foreground.
    3. Uninstall x64 background processing. If you do this, background and foreground processing will both be in 32-bit Python and both will "see" your Anaconda distribution. See this guidance for more information about the x64 environment.  
    4. If you really want Anaconda x64, install it and follow these instructions to configure it to work with the ArcGIS x64 environment, which is installed at C:\Python27\ArcGISx6410.2.

Testing and Troubleshooting

  1. Start ArcMap
  2. type "import pandas"
  3. type "pandas."
    1. A popup menu with a list of pandas-provided functions is a pretty good sign the install succeeded.

If you get an error message when you try to import, the most common cause I've seen is that the version of the module is still too new. In the pandas example, version 0.10.1 also appears to use the same 1.6.1 version of numpy but for some mysterious ESRI-specific reason that we could not get support to solve or really talk about, pandas 0.10.1 does not work. The solution was to modify the Anaconda "esri" environment to hold 0.10.0 pandas and all worked. To do change this: 

  1. Get to the Anaconda Command Prompt (via the Start menu on Windows, e.g.)
  2. Type "conda install -n esri pandas=0.10.0"



How to do a separate Python installation with ArcGIS? (GIS Stack Exchange)

Using ArcPy with Anaconda (PyMorton)

  • No labels