Before you Begin

Overview

Assuming many are new to ArcGIS and Python, some background will be useful. Since ArcGIS Pro is becoming (actually is) mainstream (ca 2021), the scripts, documentation, and videos refer to ArcGIS Pro (and the supported version of Python, currently 3.x). Some scripts and documentation do refer to ArcGIS Desktop. The main differences for Python used for GIS processing in Desktop vs Pro is the syntax for the print statements and the mapping module. See the Mapping Section for more details.

  1. Using ArcGIS desktop products (Pro or Desktop) require a Windows OS. Mac’s running a Windows partition can run ArcGIS. Chromebooks are not supported.
  2. The Python Clone (ArcGIS Pro) will need to be created or updated. This is required for every major Pro update (e.g. 2.6 – 2.7). “Security” updates (typically the 2.x.x value) do not require a clone update. See below for more details of when and how to update the Python Clone.
  3. Scripts are written in Interactive Development Environments (IDEs). I typically code in IDLE (the default editor that comes with Python) or Spyder (one of many). Both color code different types of script syntax. Spyder looks cool and does have “some” code completion. I pretty much use IDLE the majority of the time. I don’t have time to troubleshoot student IDE problems (let alone my own). If I didn’t teach, I would probably use Spyder. There are many more IDEs out there. You can even use NotePad or NotePad++…you just can’t run the script from those applications. See below for more details.

Making sure Pro is Set up to Write Code

Once Pro is installed, one can start writing Python code within Pro (if they want), but this really isn’t in the spirit of automating geoprocessing tasks in the wee hours of the night or for someone (like yourself or a colleague) to run multi-step geoprocessing task without having to click on the litany of tools, fill in parameters, and click Run a thousand times.

When I refer to “writing code,” I mean author and troubleshoot “stand alone” scripts….this is where the pain and agony occur trying to figure out the process logic, the syntax, the looping, the conditions….wanting to put nails through your head it’s so frustrating…..and then beauty and relief come with a script that actually works and does what it is supposed to do…..you feel the exhilaration Ralphie did when he got his Red Ryder BB Gun for Christmas!

…but to start on this journey, one has to Clone the Python environment in Pro because we want to use the latest and greatest software from ESRI and use Python 3.x. If you end up keeping up with the latest and greatest from ESRI, you will probably need to “clone/reclone” the Python environment once a year. ESRI seems to be pushing out more frequent major Pro updates.

Identify When the Python Clone Needs Updating

Python needs cloning (or remove the existing clone and create a new clone) when Pro upgrades from one major version to then next (e.g. 2.6 – 2.7). This video shows when you need to update the Python Clone.

Creating a New Python Clone

This video explains how to either create (if you are creating a clone for the first time (or needing to create a new clone because you removed the outdated clone (which shows a stop sign with a red exclamation point).

Starting a Python Script Editor (IDLE or Spyder)

Now – once you’ve gone through all of that, you can start writing a “stand alone” script….meaning, you write and run a script that doesn’t require Pro to be open.

In this video, I am “NOT” running a GIS Python script. Just a little “hello world,” print statement so you can see how to actually start up IDLE, create, save, and run a script. I do the same thing for the Spyder IDE for those of you who want to use a different IDE than IDLE.