Getting Started with Conda and ArcGIS Pro 1.3

Python is an incredible tool for streamlining workflows and doing analysis with ArcGIS. However, until now it was frustratingly difficult, or practically impossible to take advantage of the plethora of packages available to streamline workflows, and make life much easier for scripting. With ArcGIS Pro 1.3 comes the ability to take advantage of all these packages through the Conda package management system. Getting started, while not outrageously difficult, does have a few caveats.

First, you will need the Python Command Prompt as the Administrator. This is not the same as the Python Interactive Terminal. This can be started on a Windows 7 machine by going to Start > All Programs > ArcGIS > ArcGIS Pro and right clicking on Python Command Prompt and selecting Run as adminstrator.

opening Python Command Prompt

Next, you will need to use Conda commands to manage packages. This is not difficult. The basics you need are to list (> conda list), search (> conda serach) install (> conda install) , remove (> conda remove) and update (> conda update) packages. These five commands will take care of 90% of what you need to do.

Take for instance a really useful package for web scraping, Scrapy. Up until now, I have never been able to get this installed successfully on a Windows machine running ArcGIS so I can use the two together. Now though, it takes about a minute. Here is how to do it.

First, it may be useful to see what is on the machine. In the Python Command Prompt, we can use > conda list to see what we already have to work with.

ArcGIS Pro default package list

As you can see, there is already quite a bit included. However, as we can see Scipy is not there. To see if it is available, use > conda search scrapy.

searching for Scrapy

There are a few versions available. Looking at this list, Scrapy 1.1.1 is available for Python 2.7, 3.4, and 3.5. Since this is Python 3.4, we are good to go. We can start installing it by using > conda install scrapy.

installing Scrapy

If you decide to install this, your prompt will include a lot more going on since there are other packages Conda will install along with Scrapy. These are packages Scrapy depends on to run. Previously my hangup was I could never seem to get lxml installed successfully. Conda took less than 10 seconds to take care of this.

Now, if we decide to update or remove Scrapy, we can just use > conda update scrapy or > conda remove scrapy. This definitely makes life much easier.

Finally, if you have read this far, you likely want to know what is going on. While I do not yet understand a whole heck of a lot, here are a few things I do know. First, you have to run the Python Command Prompt as Administrator since packages are being installed under the C:\Program Files... directory. Windows requires you to have elevated privileges to make changes to anything in this directory. Second, when right clicking and starting the Python Command Prompt, you are actually calling a batch file, C:\Program Files\ArcGIS\Pro\bin\Python\Scripts\proenv.bat. This batch file takes care of ensuring you are working in the correct Conda environment. Beyond this, I am still learning as well, but I most definitely am stoked to have the entire Python package universe at my fingertips to play with!

Note: There is a boatload more information and explanations in an article on GeoNet, Python and ArcGIS Pro 1.3: Conda