Choosing a Python Scripting Environment

by | Dec 5, 2016

This blog post investigates the various options available for writing Python scripts using ArcPy.

There are various software options for writing a Python script and it´s advisable to be aware of these, along with their capabilities and shortcomings. While it is common to have multiple Integrated Development Environments (IDE’s) installed on one machine, there is no such thing as a “best option” – what is best depends mostly on personal preference in combination at the options that a specific IDE gives you. If you are just starting with Python, you might want to start with the pre-installed scripting environments before moving to a feature-rich IDE, for example.

Python window in ArcMap

As Python is an interpreted language rather than a compiled language, it is executed line by line, making it an interactive language. The Python Window is a good example of this: it offers an interactive interpreter with a Help window where you can type in and execute code by hitting enter once you´re done. It´s not meant for carrying out long scripts but is a good starting point for learning Python, as it offers interactive help, autocompletion and automatic indentation.

Python interpreter

You can also run Python by opening the python.exe file in the Windows File Explorer. This will open up a command prompt that functions like an interactive shell where you can start coding. You can also use the Python interpreter to run self-contained scripts (files ending with the .py extension) by typing ‘python’ followed by the filename at the command prompt and hit enter.

IDLE (Integrated DeveLopment Environment)

The Python IDLE that is installed with the Python installation files included with ArcGIS lets you do the same thing as the Python window and python interpreter, but also lets you save and load entire scripts, as well as run them. There’s no interactive help or autocompletion, nor is there any support for debugging so the options are limited.

PythonWin

This is a free Windows-based IDE that has been recommended by various ArcGIS users. This would be your choice for writing stand-alone scripts, meaning extensive code that goes beyond mere snippets like you would use the Python window or any other interactive interpreter for. It also offers an interactive window, where you see the results of your code after running or that you can use to type in commands.

PythonWin offers variable tracking, automatic code completion prompts and maintaining indentations. Unfortunately, you can use it only in a Windows environment and the program has limited debugging capabilities. Strangely, after installing you are required to create your own desktop icon or pin it to the task bar in order to access the program quickly.

PyScripter

PyScripter has quickly become an favorite among coders and is definitely worth trying if you start writing more code. It is also recommended by Esri staff. This is another Windows-only free IDE that supports code completion and performs syntax checking on the fly as you type. It also provides call tips, which are helpful tips showing the parameters from the function’s prototype, for example when you need to supply multiple arguments when specifying a geoprocessing tool. It can be installed easily and there are no prerequisite tools or libraries that must be installed first (other than Python itself).

Other options

Wing IDE Professional and PyCharm are two other recommended IDEs, as they both run on Windows and Linux. For a full list of available Python IDE´s, see this link.

Upcoming Programming ArcGIS with Python Classes

Categories

Recent Posts

Eric van Rees
Eric van Rees is a freelance writer and editor. His specialty is GIS technology. He has more than eight years of proven expertise in editing, writing and interviewing as editor and editor-in-chief for the international geospatial publication GeoInformatics, as well as GIS Magazine and CAD Magazine, both published in Dutch. Currently, he writes about geospatial technology for various clients, publications and blogs.

Sign up for our weekly newsletter
to receive content like this in your email box.