Anaconda: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
mNo edit summary
Line 3: Line 3:


My main interest in Anaconda is trying out ArcGIS with Jupyter notebook.
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.
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.
I installed Anaconda on Plover first, I can't access the ESRI "ArcPy" module from OS/X but I can use the "ArcGIS" module.

Revision as of 03:59, 10 July 2017

Don't install Anaconda, it's very big, install miniconda then add the packages you will actually use. 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

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 + ArcGIS 10.5

Read this before plunging into the Anaconda installer. https://my.usgs.gov/confluence/pages/viewpage.action?pageId=540116867

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 Anaconda in the VM that I use for ArcGIS Desktop, so that I can try Jupyter with ArcGIS.

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 ~/Anaconda3 and the 64-bit version in ~/Anaconda64
  • 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.

You can launch an "Anaconda prompt" and type DOS commands or (I have GIT installed) start a git bash shell and type

cd /c/Users/bwilson/Anaconda3
./Scripts/conda update conda
./Scripts/conda create -n arc105 python=2.7.12 matplotlib=1.5.3  scipy=0.18.1 pandas pyparsing xlrd xlwt ipython
cd /c/Users/bwilson/Anaconda64
./Scripts/conda update conda
./Scripts/conda create -n arc105 python=2.7.12 matplotlib=1.5.3  scipy=0.18.1 pandas pyparsing xlrd xlwt ipython

I tried installing the versions recommended by USGS but ended up using some that are newer. I won't know if this works until I try it.

Once you have followed all the instructions you should be able to launch an "Anaconda prompt" (either 32 or 64 bit), and then load the arcpy module. If this works, you can now use ArcPy in your Anaconda environment.

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 arc105 environment in Anaconda because if 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".

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.