Anaconda

From Wildsong
Jump to navigationJump to search

Don't install Anaconda, it's very big, install miniconda then add the packages you will actually use. Here is the Miniconda download page.

When I refer to "Anaconda" please keep in mind I am really talking about miniconda. Anaconda is convenient if you want to do one giant install and have most everything you need.

My main interest in Anaconda is trying out ArcGIS with Jupyter notebook. With ArcGIS Pro 1.4 this turns out to be very easy. Time to stop using ArcMap. ha ha ha ha

I installed Anaconda on Plover first, I can't access the ESRI "ArcPy" module from OS/X but I can use the "ArcGIS" module. ArcPy is for desktop GIS work. ArcGIS is for talking to ArcGIS Online.

I learned about using Jupyter notebook by watching an ESRI video, "ArcGIS API for Python: Advanced Scripting". I like the idea of cells and being able to visualize data directly (like displaying a dataset on a map) but at the moment I am learning to use spyder instead.

Running this code in spyder generates an error about javascript. Running it in jupyter generates a map, because it will send javascript to your browser.

from arcgis.gis import GIS
g = GIS()
g.map()

Installation

Linux

2017-Jul-09 Laysan Ubuntu. Installed miniconda3, then "conda3 install spyder" and "conda3 install -c esri arcgis"

Mac

5-13-17 Installing on Plover

Download the Miniconda installation shell script and run it. Say "yes" to modifying your PATH.

I am not putting Anaconda onto Stellar, because alas Apple won't update the operating system for her and Anaconda warns against using old versions of OS/X.

Create an environment for doing GIS work, thus keeping all the modules contained.

conda create -n gis
source activate gis
conda install spyder
conda install gdal # this installs python 3.5, 3.6 is not supported yet
conda install -c esri arcgis # this installs ESRI's python api module, "arcgis".

When you do 'which spyder' it should show the one installed in the gis environment, for me it's

/Users/bwilson/miniconda3/envs/gis/bin/spyder

Installing spyder inside the "gis" environment avoids having to mess around with settings.

Installing spyder also installs jupyter.

Windows + Python + GDAL + FGDB

I still don't have the FGDB part working but I don't really care any more since I saw the comment in the docs that it can't be used with Annotation Feature Classes. I guess that leave me with trying to get access via ArcObjects.

See also https://github.com/OSGeo/gdal and https://trac.osgeo.org/gdal and of course http://www.gdal.org/

Download the WHL file you need from https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal The one you need matches your bitness (64-bit) and your python version so 64 + Python 3.6 = GDAL?2.2.3?cp36?cp36m?win_amd64.whl for me.

So far... at an Anaconda 64 bit prompt

conda create -n gdalwhl
activate gdalwhl
conda install pip
pip install GDAL?2.2.3?cp36?cp36m?win_amd64.whl

Test before going on

python
import osgeo.gdal
gdal.__version__

should show

'2.2.3'

Download the FGDB zip from Github, https://github.com/Esri/file-geodatabase-api/tree/master/FileGDB_API_1.5.1 and unzip it

Windows + ArcGIS 10.5

Read this before plunging into the Anaconda installer. https://my.usgs.gov/confluence/display/EGIS/Using+Anaconda+modules+from+the+ESRI+python+environment

Why install 32-bit Anaconda? So that you can use the Anaconda environment to add and maintain python packages. Arguably you could replace the entire ESRI Python with Anaconda Python but I don't suggest doing this.

Why install 64-bit Anaconda? Same reason, but also so that you can work in a completely up to date and snazzy Anaconda environment that has acess to the ESRI python modules (and therefore all of the ESRI ecosystem.)

I installed Anaconda2 in the VM that I use for ArcGIS Desktop

NB:

  • I installed both the 32- and 64-bit versions, so that I can use both ArcMap and geoprocessing.
  • I put the 32-bit version in Miniconda2_32 and the 64-bit version in Miniconda2_64
  • I told it NOT to modify my PATH and NOT to change the registry, so that the versions already installed by ESRI will continue to work.
  • I installed for "Just me" because I am the only one who ever uses this computer.

I never double-click py files to run them so I don't need to change the registry.

In each environment then

Start a 32-bit conta prompt

conda update conda
conda create -n arc1051
activate arc1051
conda install  python=2.7.13 numpy matplotlib=1.5.3  scipy=0.17.0 pandas pyparsing xlrd xlwt console_shortcut spyder

You can add a bash shell here too.

conda install -c msys2 m2-bash

Start a 64-bit conda prompt

conda create -n arc1051x64
activate arc1051x64
conda install  python=2.7.13 numpy matplotlib=1.5.3  scipy=0.17.0 pandas pyparsing xlrd xlwt console_shortcut spyder
conda install -c anaconda git

I do some things with PDF files so I installed this

conda install -c anaconda-nb-extensions pypdf2

Likewise I want to be able to read Excel .xlsx files.

conda install -c anaconda openpyxl 

You can add a bash shell here too.

conda install -c msys2 m2-bash

The process of setting up the environment should create items in your Startup menu with the environment name appended, use those to get access to arcpy.

The version of Python that launches from ArcGIS will be the same one ESRI installed but it will have access to packages that you install in the arc1051 environment in Anaconda because of the 'zconda.pth' file. Naming it with a 'z' means it loads last and therefore most packages (like scipy and numpy) load from the ESRI directory and only things you have added come from Anaconda.

USGS missed only one item in there-- the 32-bit pth file to copy is Desktop.pth but the 64-bit file is DTBGGP64.pth which I assume stands for "DeskTop BackGround GeoProcessing 64-bit".

cd /c/Python27/ArcGISx6410.5/Lib/site-packages
cp DTBGGP64.pth /c/Users/bwilson/AppData/Local/Continuum/miniconda2_64/envs/arc1051x64/Lib/site-packages/

Windows + ArcGIS Pro 1.4

With AGP 1.4, ESRI installs python3 and conda for you.

https://geonet.esri.com/groups/arcgis-python-api/blog/2017/02/08/arcgis-api-for-python-101-released

Somewhere they probably even tell you how to use it. Since conda is installed I should be able to install the other components, right?

Launch a Python prompt from Start menu as administrator and then I can use conda to install packages. For example, this installs the new web API "arcgis" not to be confused with "arcpy".

conda install -c esri arcgis

This one one way, it is still possible to install Anaconda separately if you want.