ArcGIS Pro + Conda + Jupyter Notebook + ArcGIS Python API
ArcGIS Pro, like it's predecessor ArcMap, installs Python tightly integrated with the software. ArcGIS Pro 1.4 installs Python 3.5 complete with the Conda package management system. The environment ArcGIS Pro uses is actually even a Conda environment named arcgispro-py3
.
This means it is not very difficult at all to install third party packages using either pip
or Conda. The only challenge is if you are trying to follow any of the Conda documentation, none of the command line options actually work unless you access the command line from the start menu option Start > Programs > ArcGIS > Python Command Prompt. This automatically starts a command prompt with the correct Python environment activated, arcgispro-py3
.
If you are like myself, and want to have the normal Conda commands function as expected from the command line, it is helpful to add the Scripts directory to your system path environment variable. The full path you need to add is C:\Program Files\ArcGIS\Pro\bin\Python\Scripts
.
While there are plenty of resources detailing how to navigate to the correct location to accomplish this, I prefer to use the following snippet in a Command Prompt window running as Administrator.
setx path "%PATH%;C:\Program Files\ArcGIS\Pro\bin\Python\Scripts"
Running a command prompt as administrator is as simple as right clicking on the link to launch cmd, and selecting run as Administrator
. Paste in the aforementioned command, and you will be able to run normal Conda commands from any command prompt.
To work with the Conda environment installed with ArcGIS Pro, you will need to activate the arcgispro-py3
environment first by typing activate arcgispro-py3
. Then, the environment name will prepend every line in the command prompt, reminding you this is the active environment.
Then you will be able to use the normal conda commands to modify the environment ArcGIS Pro uses. Notably, this means you can add useful packages to this environment such as Sci-Kit Learn or Scrapy to use with the rest of the capabilities available with ArcGIS Pro by simply typing conda install scikit-learn
or conda install scrapy
. True, you can also do this through the ArcGIS Pro interface, but I prefer the command line, so getting this working is preferable for my workflows.