GEOG 489
Advanced Python Programming for GIS

1.9 Investigating IDEs

PrintPrint

ArcGIS Pro does install an IDE by default (IDLE which can be accessed from a conda prompt by typing idle) and there is also the straightforward installation of spyder which we covered when we started looking at writing Python 3 code for ArcGIS Pro.

The benefit of using an IDE like spyder is that for more complicated coding and particularly debugging, we have tools that enable us to step through our code line by line, debug and profile multiprocessing code, and watch what is happening in our variables as we saw earlier in the lesson.

While we've had you install and use spyder a little there is a wide range of IDEs that you could use. We’ll provide a brief overview of some different IDEs and code editors in case you would like to use something else (and the choice is entirely yours). Esri supplies a link to a list of IDEs that work with Anaconda (the implementation of conda used for ArcGIS Pro).

Homework Assignment

Part of the homework assignment for this lesson involves selecting an IDE and reviewing it. For full details see the Assignment Page.

Since Python is used in so many different fields and for so many different purposes, there are multiple places Python can be written and edited, and we have seen some of these already.

Some ways are fairly straightforward. You can create a text file, write your Python code, save it with a “.py” extension, and execute it on your computer. However, this approach gives you little to no assistance with writing your code or debugging it.

Because writing code can be such an intensive process, Integrated Development Environment (IDE) applications were developed. Depending on the complexity of the IDE, IDEs can assist developers in a multitude of ways. Many IDEs exist for many different languages, but several focus particularly on Python. Typical Python IDEs include a source code editor and debugging tools. Extended features in some IDEs include

  • code auto-completion,
  • syntax checking,
  • version control,
  • environment control,
  • and project organization.

IDLE (Python GUI)

IDLE is installed with ArcGIS Desktop software when Python is also installed. IDLE offers very basic code editing capabilities and color codes objects, functions, and methods so users can easily differentiate parts of their code. IDLE also includes a basic debugger that reports messages and errors back to the user. IDLE has some simple text editing tools for bulk indenting, dedenting, commenting, and tabifying.

PythonWin

In GEOG485, we used PythonWin coming with ArcGIS Desktop as the course IDE (until we changed to ArcGIS Pro recently). PythonWin offers a bit more coder assistance and debugging tools than IDLE. For example, the debugger can step through code line by line so you can see exactly what’s going on with your code. 

PyScripter

Downloading and Installing

PyScripter is an open-source IDE available for download at SourceForge's PyScripter page. The full project is also available on GitHub at their pyscripter page. Each download of PyScripter installs several different versions of PyScripter so you can select the right one for the version you’re developing in. Developing in the wrong version of Python can lead to compatibility issues and lost functionality.

screenshot of all the different python versions
Figure 1.31 PyScripter installs multiple versions of the IDE so you can choose the right Python version for your project.

If you want to use PyScripter to develop code to be used in ArcGIS Desktop software, you will want to know ahead of time that ArcGIS Desktop uses Python 2.7 and that ArcGIS Desktop is a 32-bit software program. On SourceForge, the PyScripter version is not related to any Python version, so you’ll probably just want to download the latest version of PyScripter without the term “x64” included in it. As you can see in Figure 1.31, this installation of PyScripter will include versions for Python 2.4 through 3.6. For ArcGIS Desktop, you’ll want to use PyScripter for Python 2.7.

If you want to use PyScripter to develop for ArcGIS Pro or to use the ArcGIS API for Python, you’ll want to download and install the latest version that includes “x64.” To check and see what version of Python ArcGIS Pro is using, open ArcGIS Pro, and on the “Analysis” tab, open the Python interpreter. Inside the Python interpreter, type in the following lines:

import sys 
sys.version_info 

The Python window will report back what version of Python ArcGIS Pro is using so you can use the corresponding PyScripter version. In Figure 1.32, the version used is 3.5.3, so PyScripter for Python 3.5 would be used.

screenshot of the above code resulting in version information
Figure 1.32 How to see what version of Python ArcGIS Pro is using.

Using PyScripter

PyScripter has many tools available for making developer’s lives easier. The source code editor includes auto-completion and a built-in syntax checker. Each developer can also customize certain parts of the interface based on their personal preferences. PyScripter also has more advanced debugging tools than IDLE or PythonWin.

PyCharm

PyCharm is another popular IDE that has a free community edition available to download- see the Jet Brains Download PyCharm page. PyCharm differs from PyScripter the most in that PyCharm integrates easily with conda, so developers can specify which conda environment a project needs to be developed in and run on. PyCharm has many different development aids and tools available including auto-completion, enhanced debugging, various integrated code-checking processes, error detection, and on-the-fly code fixes.

Python Tools for Visual Studio

Microsoft has a plugin for Visual Studio so it can be used as a Python IDE. Visual Studio has Community Editions available for free download, and Python Tools for Visual Studio can be downloaded and installed- see Microsoft's How to Install Python Support in Visual Studio on Windows page. For Visual Studio 2015 and lower, you must also install a Python interpreter. Visual Studio is a robust IDE with organization tools that can integrate project components from various source code languages as well as auto-completion and enhanced debugging. Visual Studio can also be used to directly debug certain Python components in ArcGIS Pro including script tool execution, tool validation, and Python toolboxes.

Others

There are multiple other Python IDEs available, and what to pick usually depends on a developer’s personal preference. Others include Eclipse/PyDev, Eric, and Spyder of course.

For more information about IDEs in general, feel free to refer to these links: Wikipedia's page for Integrated Development EnvironmentEsri's Technical Support Page, and ArcGIS Pro's Debug Python code page.