ArcPy Outside of ArcMap/ArcPro

One of the more problematic issues I’ve come across is accessing ArcPy outside of the bundled software that comes with an ArcGIS Pro installation. If you google “how to access arcpy outside of arcgis,” you’ll get answers like this Stack Exchange post or this community blog answer in ESRI’s forums. I wasn’t a fan of these type of solutions. They’re too convoluted and hacky.

While I haven’t posted about Python previously, my current job has me working almost exclusively in Python, with some SQL here and there. For GIS tasks, I highly recommend the anaconda installation of Python. While you can use their GUI, I recommend their command line interface miniconda for more control.

There are some specific quirks, pros, and cons of doing this which I will detail further below. Before we begin, it is important to note that this is not a way to get around having a valid ESRI license. You will need a valid installation and license in order to use ArcPy. You will also need to know the version of ArcGIS Pro you have installed (cause at this point, only stubborn mules and legacy systems still use ArcMap).

After you’ve installed Python via Anaconda/Miniconda, you will need to open the Anaconda Prompt (not the powershell). Because ArcGIS Pro 3 is still very buggy, I’ll deal with how to work with ArcGIS Pro 2.9. I recommend you create a new environment for ArcPy (cause ArcPy has some old dependencies that could seriously hurt you elsewhere). I call my new environment esri (inventive, I know), but really you can name it anything you want. Its very important to note the version of python being installed. It is a dependency. Please reference the table below to determine the version of python you will need to install based upon the version of ArcGIS Pro you are running.

conda create --name esri python=3.7
ArcGIS Pro VersionPython Version
2.7 – 2.93.7
2.3 3.6
AcGIS Pro version x Python version

If you’re running ArcGIS Pro 3.0, then you would want to set python=3.9 and accordingly for any new and future versions.

After Anaconda has created your new channel, you’ll need to activate it. You can do so by typing the following line.

conda activate esri

You will know the new environment is active because it will appear in parenthesis to the left.

Now for the magic. ESRI actually maintains a channel on Anaconda. That’s where you’ll install ArcPy using the following line in your command prompt. It is important to note that you will need to install the version of ArcPy that corresponds with the version of ArcGIS Pro that you have installed on your machine. During the installation of ArcPy, it will look for a valid licensed and installed version of ArcGIS Pro. If you do not have one installed, it will not allow ArcPy to be installed.

conda install -c esri arcpy=2.9

If all goes well, you now have ArcPy installed on your machine, independent of your ArcGIS Pro installation.

An important caveat. ESRI doesn’t really update anything. What this means for you is that a lot of the packages will be old, and in some cases, deprecated. For example, my Python IDE of choice is Spyder. Spyder, as of the writing of this post, is at version 5.2.2. By installing ArcPy, and its associated dependencies, I’m limited to Spyder 3. Yeah, thats two major versions ago. However, because ESRI does utilize Jupyter Notebook, you could also install Jupyter Notebooks as your IDE for when you need it.

Hope that helps someone out there.

Leave a Reply

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

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

Facebook photo

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

Connecting to %s