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.
Comment: added ipython instructions

...

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

Code Block
languagepy
>>> 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 a custom Anaconda environment (including pandas) that is compatible with ArcGIS 10.2.2.

...

  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 pyparsing=1.5 xlrd=-0.9.2 xlwt=0.7.5" 
  3. Anaconda's conda command will then:

...

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:

 

Code Block
languagetext
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

...


...

...


[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 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).

Let's add the pandas module.

Specifying python, numpy, and matplotlib versions makes sure the environment will still work with ArcGIS tools. , and Anaconda determines the most recent compatible version of pandas (in our case, 0.13.0).

Code Block
languagetext
conda install -n arc1022 python=2.7.5 matplotlib=1.3.0 numpy=1.7.1 pandas

...


...

...


The following NEW packages will be INSTALLED:

...


pandas: 0.13.0-np17py27_0 

...

### 

...

this version works with python 2.7 and numpy 1.7
... 

A few of the most popular things to add to your environment is interactive python ("ipython"), in several flavors:

Code Block
languagetext
conda install -n arc1022 python=2.7.5 matplotlib=1.3.

...

0 numpy=1.7.1 ipython ipython-notebook ipython-qtconsole

You can search for more packages available in conda with conda search.

You're not limited to adding only packages to which conda has access to your new environment. Here's an example on how to install a commonly desired GIS-related package (shapely) into a conda virtual environment using the python pip utility:

...

  1. Install Anaconda, setup environment to match your ArcGIS version
  2. Edit the paths in this script (usercustomize.py.txt) to match your setup
  3. Put the script in the Python user site packages folder (must be named usercustomize.py)
    The user site-packages folder path can be found with: "python -m site --user-site".
    This is usually:  C C:\Users\%USERNAME%username\AppData\Roaming\Python\Python27\site-packages 

...

  1. packages

Testing and Troubleshooting

...