Review: 6 Python IDEs go to the mat

See how IDLE, Komodo, LiClipse, PyCharm, Spyder, and Python Tools for Visual Studio stack up in capabilities and ease of use

1 2 Page 2
Page 2 of 2

LiClipse provides precise controls over the runtime environment for Python projects. When you create a new project, you can choose which Python interpreter to associate with it, and what PYTHONPATH to use with specific launch configurations. This is useful if you have different revisions of Python installed side-by-side, and you want to ensure that a given project runs with a specific Python version. You don’t even have to use a Python interpreter that has been registered with the system; it can be an executable in a folder somewhere. The JVM-based Jython and the .Net CLR-based IronPython (which is back under active development) are also supported, along with the stock CPython interpreter. (PyPy is not explicitly supported, but should work as a drop-in replacement for CPython per its stated goals.)

PyDev provides a code analysis component, so any Python file open in the editor can be parsed in the background and annotated with syntax markup. Which errors or warnings to flag, and how they’re highlighted, is all user-settable. You can automatically apply Python’s PEP8 code-formatting rules to a document as part of the code analysis, a nice way to ensure that source code remains consistent throughout and across projects. Note that autoformatting longer files (in my case, a couple thousand lines) causes a notable delay of a couple of seconds.

The code analysis also includes screening for common gotchas like undeclared variables, unused or redefined imports, and duplicate function signatures. Errors caught by this analysis can be highlighted in the “overview ruler,” the strip at the right-hand side of the editor that provides a graphical map of the current file. You can choose what highlighting, if any, to apply to lines of code that are flagged by these checks, and you can manually suppress warnings by way of comments. For example, #@UnresolvedImport will silence a warning about an import that is never used.

Another powerful PyDev utility included in LiClipse is the refactoring system. Classes, methods, attributes, imports, and local variables can be intelligently renamed. Best of all, LiClipse gives you a sneak preview of the changes before they’re applied. This preview works across your entire project, not only in the current module, allowing you to apply the changes selectively—for instance, if you’re trying to work around the limitations of a dynamic import or another item that generates difficult-to-predict side effects.

LiClipse provides a debugger in a dedicated view or, in Eclipse terms, a “perspective.” The debugger supports both setting breakpoints and manually suspending execution, and it lets you inspect most every aspect of the running Python app: the call stack, the modules and variables in each stack frame, and much more. Breakpoints can be set for whenever a given Python exception is triggered, including your own custom exception types and exceptions raised by Django templates. Caught exceptions can be piped into a separate console for later analysis.

LiClipse ships with a reasonably trim set of useful Eclipse add-ons. For instance, a Git client allows LiClipse projects to be integrated with local or remote repositories. Other tools bring text editing enhancements and file manager integration. You’ll most likely want to keep these add-ons, but you can always disable them if you don’t use them.

liclipse pydev

The PyDev and LiClipse combo uses the existing Eclipse IDE framework for Python development—good for those already familiar with Eclipse, challenging for those who aren’t.

Python Tools for Visual Studio

If you already use Visual Studio in some form and are adding Python to the mix, using the Python Tools for Visual Studio add-on makes perfect sense. Microsoft’s open source plug-in provides prepackaged access to a number of common Python frameworks, and it makes Python debugging and deployment functions available through Visual Studio’s interface in the same manner as any other major language.

When Visual Studio 2015 came along, InfoWorld’s Martin Heller was impressed by its treatment of open source languages as first-class citizens right next to Microsoft’s own. Those languages included Python, and with the heartening level of support Visual Studio now provides for Python, it's worth taking seriously as a dev environment for the language, no matter what kind of project you’re building.

There are two ways to get set up with Python on Visual Studio. You can add the Python Tools to an existing installation of Visual Studio, or you can download a stub that installs Visual Studio from scratch and adds Python Tools automatically. Both roads lead to the same Rome: A Visual Studio installation with templates for many common Python application types.

Out of the box, Python for Visual Studio can create projects that use some of the most widely used Python web frameworks: Flask, Flask with Jade (a templating language), Django, and the Bottle microframework. Also available are templates for generic web services, a simple command-line app, a Windows IoT core app that uses Python, and an option to create Visual Studio projects from existing Python code. I was pleased to see templates for IronPython, the revitalized Python port that runs on the .Net framework.

When you create a new project using one of these frameworks, Visual Studio checks to make sure you have the dependencies already available. If not, it presents you with a few choices. You can create a Python virtual environment and have the needed packages placed there; you can have the packages installed into the Python interpreter available systemwide; or you can add the dependencies to the project manually. One nice touch is that Visual Studio logs all the steps it takes when it sets up a project, so you know what changes have been made and where everything is.

Visual Studio’s Solution Explorer contains not only the files associated with each of your Python projects, but also the accompanying Python environment, as well as any Python packages installed therein. Right-click on the environment and you can install packages interactively with Pip or Easy_install, automatically generate a requirements file, or add folders, Zip archives, or files to the project’s search path. Visual Studio automatically generates IntelliSense indexes for Installed environments, so the editor’s on-the-fly suggestions are based on what’s installed in the entire Python environment you’re using, not only the current file or project.

Smart techniques for working with Visual Studio’s metaphors abound. When you launch a web app for testing, through the green arrow launch icon in the toolbar, Visual Studio’s app launcher pops open the default web browser (or the browser you select) and points it at the app’s address and port. The Build menu has a Publish option that can deploy your app on a variety of cloud services, including Microsoft’s Azure App Service.

Be cautious of folder depths and path lengths when dealing with Python Tools for Visual Studio. One of my projects was created in a deeply nested folder, along with its virtual environment. When I attempted to upgrade the packages for that virtual environment, the upgrade process crashed, and at one point I was left with a broken environment where I couldn’t even run the Pip package manager anymore. I was able to fix the problem by moving the project to a folder much closer to the root of the drive and creating the virtual environment for it there. It’s not clear to me if this is a problem with Visual Studio or Python itself, but it’s worth noting.

Python Tools for Visual Studio provides a built-in facility for running the PyLint code analyzer. As with other Visual Studio features that depend on external packages, Visual Studio will attempt to install PyLint if you haven't yet set it up. Unfortunately, the installer needs a path to the Visual Studio compiler, and Visual Studio’s launcher for the installer doesn’t seem to provide it correctly (you get the infamous “ValueError: Unknown MS Compiler version 1900” crash). Your best bet is to install PyLint by hand, so you can provide the necessary environment variables.

I was disappointed by the absence of support for Cython, the project that allows Python modules to be compiled into C extensions, DLLs, and standalone executables. Cython uses Visual Studio as one of its compilers, but there’s no support for Cython-format files in the Python Tools for Visual Studio, nor direct support for compiling Cython modules in Visual Studio.

python tools visual studio

Microsoft’s Python Tools for Visual Studio add-on includes quick ways to build common Python-based web apps and deploy them to the cloud. It also makes good use of the Visual Studio UI to provide access to the components of a Python development environment, like the package manager.

PyCharm

If Eclipse seems too clunky and intimidating, PyCharm from JetBrains has much the same level of power, but a friendlier presentation to the user. PyCharm is outfitted with features gleaned from close study of how Python developers work and how Python applications are assembled. It has something to appeal to almost every kind of Python developer: the newcomer, the seasoned pro, the developer of web apps, and the data scientist.

PyCharm has a malleable interface like LiClipse, but it’s less difficult for a newcomer to grasp. All the most important items for getting a Python project off the ground are exposed in the default view. Panels that show the project’s file layout, the structure of the module currently in focus, and the run/debug/terminal consoles are all available as widgets that can be exposed or hidden by clicking on the sides or bottom of the IDE window. You can group together sets of open files as “tasks,” for instance, if you want to work on the all the configuration files for a given project at once. That’s an option, not a requirement.

The Python-centric features of PyCharm don’t stop at developing in the language, but extend to working with its larger ecosystem. Jupyter notebooks, in the .ipynb file format, can be opened and edited directly in PyCharm. This isn’t simply a read-only view; you can actually run cells within notebooks. For a data scientist working with notebooks and running regular Python projects, this is a fine option to do both under one roof.

Another nice out-of-the-box boon—albeit only in the for-pay edition of the product—is support for Cython, the project that compiles Python modules into C extensions. You still have to install Cython yourself and set up your C compiler to make full use of it, but PyCharm includes syntax highlighting and code completion for Cython code. This is even more useful given that Cython is not quite Python or C, so syntax highlighting for either of those alone won’t help Cython users.

With dynamic languages like Python, it's challenging to implement some functions common to IDEs, like refactoring. PyCharm allows object names to be refactored throughout a project, but its implementation takes Python’s behaviors into account. When you preview the refactoring operation, it provides a list of all the functions that are guaranteed to be changed and any likely candidates based on a code analysis. In the same vein is the “safe delete” function, which checks to make sure any deleted symbols are not used.

Some Python-specific features need to be approached with caution. The “Clean Python Compiled Files” option sweeps all of the precompiled .pyc files out of the project directory. Be careful with this option, as it removes all such files, not only those in __pycache__ directories. If you apply it to a codebase where .pyc files are used in lieu of regular .py files, you’ll delete those files and break your app.

Plenty of other features in PyCharm will please conscientious developers. One of the panels presented by default in the IDE is a TODO list, also found in LiClipse. Click TODO and everything marked TODO: or FIXME: in your code is presented in a tree view. You can add other keywords to search for if you’re in the habit of peppering your code with them. If you open a file in PyCharm that's outside the scope of the current project, you’ll be warned, but you can select “I want to edit this file anyway” and get on with tasks.

Like the other JetBrains IDEs, PyCharm comes in a free community edition and a paid professional version. Most of the differences amount to direct support for features used in enterprise environments. Among them is the aforementioned support for Cython, integration with Docker, direct support for popular frameworks like Django, and IDE-level support for HTML, JavaScript, and database solutions.

pycharm

The PyCharm community edition (shown here) is more than good enough to satisfy most basic Python development needs. The for-pay version adds enterprise features like Docker and Cython support.

Copyright © 2016 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2