Heard of Conda? Wondering how it relates to using Python in ArcGIS Pro (version 1.3)?


apro1-3After installing ArcGIS Pro 1.3, you may notice a few changes. The scope of this blog will detail Conda – what it is? why this change occurred? and how conda has affected the usage of ArcGIS Desktop functionality when used by ArcGIS Pro? – specifically as at version 1.3 (and later releases).

For those reading, I am assuming your understanding of python is that when used in both ArcGIS 10.x and ArcGIS Pro, this is the primary language to automate, configure and consume your GIS ecosystem. One of the cornerstones within each ecosystem is knowing which package you have installed. The awareness or realisation of these different python packages can be time consuming and require proactive management when being aligned to system dependencies (e.g. NuGet Package Explorer for anyone interested is worth a look).

But… don’t despair, Esri has kindly adopted Conda and made life easy for us all.

condaSo, what is Conda you ask? … Conda is a package manager application that quickly installs, runs, and updates packages and their dependencies. For example, you may have one environment with NumPy 1.7 and its dependencies, and another environment with NumPy 1.6 for legacy testing. The take home message here is if you change one environment, your other environments are not affected.

What does this mean within ArcGIS Pro… ArcGIS Pro 1.3 has a single conda environment, arcgispro-py3, that includes all Python libraries used by ArcGIS Pro as well as several others such as scipy and pandas (a fantastic data manipulation and analysis site package). With an install of ArcGIS Pro for “all users”, arcgispro-py3 will be found at r”C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3”. In future releases, you’ll be able to create and change conda environments within ArcGIS Pro. So, while working on a given Pro project you could create and use a new conda environment with specific sets and versions of Python packages.

The thinking behind this is… all of the hurdles will be removed when writing Python code. It will support installing open-source and third-party libraries that are associated with an individual project, rather than into the base Python installation (Python-3.4.3 for the Pro platform).

As you can see from the below figure, I have returned a list of the conda package “arcgispro-py3” contents and version numbers using the “conda” command (refer to Conda command cheat sheet for more info).

blog_conda_csherwin

Please note, I accessed this using the “proenv.bat” file, which activates the ArcGIS Pro environment and readies the command prompt instance for any call you make. For example: a good tip is to type ‘python’ to start an interactive terminal session (REPL session), or type ‘python’ followed by the name of the script you wish to run.

So why can’t I just use c:\python34\python.exe to run my ArcGIS Pro scripts?… For those coders familiar with using command prompt (utilising ordered arguments through sys.argv or arcpy.GetParameterAsText), if you browse to “C:\Program Files\ArcGIS\Pro\bin\Python\python.exe” with intent to use this install of Python, you will be mistaken. This is not the Python you’re looking for. You will not be able to use the arcpy module when running with this interpreter.

So how does conda work when running standalone python scripts… In short, you need to use “propy.bat”. Located at r”C:\Program Files\ArcGIS\Pro\bin\Python\Scripts” (assuming an ‘all users’ setup), propy.bat is a replacement for python.exe and its purpose is to activate the ArcGIS Pro conda environment (arcgispro-py3), launch python (3.4.x) and run the specified python file. If you only want the interactive window mode of the conda environment (python 3.4.x), simply double click the propy.bat file to access and away you go.

For more information on this, including which IDE’s are recommended to use a conda environment (such as PyCharm, Spyder), a great reference for is this Esri Geonet blog

Thanks for reading!!

Chris Sherwin

Esri Australia Support

 

 

Got something to say?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s