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 myusgs@usgs.gov. Thank you for your prompt attention to this matter.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • 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

...

MiniConda (Single-User - no admin access needed)

...

Miniconda only includes the minimal Python (the main distribution now includes R and many other packages and is very large).

Download MiniConda for Python 2.7
Download links: ( x32 | x64 ) (save do not run link)
The 32-bit version works with ArcGIS Desktop (which is 32-bit)
The 64-bit version is optional, but required to use Anaconda with ArcGIS background processing (and Pro)

Run the .exe installers

Select install for a single

...

user (Not "All Users")

  1. Install to a folder where there is going to be plenty of space (recommend the D drive, not the C drive)
  2. IMPORTANT: To avoid breaking ArcGIS, uncheck the checkboxes  (a) make Anaconda the default Python and (b) add Anaconda's Python to the PATH. 
  3. Here are screenshots to help guide you through the install process.

Set up the console shortcuts

Go to each of your anaconda folders and set up Start menu shortcuts for Anaconda

 

Warning

Python 2.7.11 has a registry conflict with ArcGIS Desktop 10.3. This must be fixed before you continue:

Esri KB 45924 http://support.esri.com/en/knowledgebase/techarticles/detail/45924

 

At

Code Block
languagepowershell
linenumberstrue
cd D:\Users\cprice\Anaconda32\Scripts
conda install console_shortcut
cd D:\Users\cprice\Anaconda64\Scripts
conda install console_shortcut

 

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

...

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

Open ArcMap and its Python window, and enter these commandsThe critical modules for compatibility can be found your version of ArcGIS from a command line:

Code Block
languagepy
>>> C:\Users\jwpowell> C:\Python27\ArcGIS10.2\python.exe -c ^
"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 environment

...

for use with ArcGIS

...

The critical modules for compatibility are the three above. We'll also include a few others other modules that we know are shipped in the ArcGIS 10.2.2's Python stack.

  1. Get to the Anaconda Command Prompt (Start > Search > Anaconda, pick "Anaconda Command Prompt"each of your Anaconda startup shortcuts)
  2. Type (depending on Arc version):
    ArcGIS 10.2.2:  "conda create -n arc1022 python=2.7.5 numpy=1.7.1 matplotlib=1.3.0 pyparsing xlrd xlwt" 
    ArcGIS 10.3.1:  "conda create -n arc1031 python=2.7.8 numpy=1.7.1 matplotlib=1.3.0 pyparsing xlrd xlwt"
    ArcGIS 10.4.1"conda create -n arc104 arc1041 python=2.7.10 numpy=1.9.2 matplotlib=1.4.3 pyparsing xlrd xlwt"
  3. The conda tool will:

...

Since this new custom environment is not the Anaconda default, you need to let it know that's what you want to use. Then, you'll ask it to tell you what's installed. So, at the Anaconda Command Prompt, type:

Open an Anaconda command window and load the virtual environment

 

Code Block
languagetext
C:\Users\cprice> conda info --envs
# conda environments:
#
arc1022                  D:\Users\cprice\Anaconda32\envs\arc1022
root                  *  D:\Users\cprice\Anaconda32
D:\Users\cprice>activate arc1022
Activating environment "arc1022"...
[arc1022] D:\Users\cprice>condacprice> conda list
# packages in environment at D:\Users\cprice\AnacondaAnaconda32\envs\arc1022:
#
dateutil                  2.4.1                    py27_0
matplotlib                1.3.0
np17py27_0numpy                np17py27_0
numpy                     1.7.1                    py27_3
pip                       8.1.1                    py27_1
pyparsing                 1.5.
[arc1022] D:\Users\cprice>python
Python6                    py27_0
pyside                    1.2.1                    py27_0
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.
>>>                         2
python-dateutil           2.4.1                     <pip>
pytz                      2016.4                   py27_0
setuptools                21.2.1                   py27_0
six                       1.10.0                   py27_0
wheel                     0.29.0                   py27_0
xlrd                      0.9.4                    py27_0
xlwt                      1.0.0                    py27_0

D. Add more packages

You can add more packages using conda install, but make sure you specify version numbers for these that won't change the environment's version of python or numpy (or ArcGIS will not be able to use that environment anymore).

...

3) Configure ArcGIS to see Anaconda and vice versa

This can most easily be done (personal opinion) with a Python startup script

  1. Install Anaconda, setup environment to match your ArcGIS version
  2. Edit Download and edit the paths in this script (usercustomize.py.txt) to match your setupPut
  3. IMPORTANT - Debug this script by running it from python.exe 
  4. Place the script in the Python user site packages folder (must be named usercustomizewith the name usercustomize.py)
    The user site-packages folder path can be found with:  python -m site --user-site
    Usually it is:  C:\Users\username\AppData\Roaming\Python\Python27\site-packages

...