Of all the metrics you could use to gauge the popularity and success of a language, one surefire factor is the number of development environments available for it. Python's rise in popularity over the last several years has brought with it a strong wave of IDE support, with tools aimed both at the general programmer and those who use Python for tasks like scientific work and analytical programming.
These six IDEs with Python support cover the gamut of use cases. Some are multilanguage IDEs that have Python support through an add-on or a repackaging of another product with Python-specific extensions. Each benefits a slightly different audience of Python developer, although many strive to be useful as universal solutions.
A good number of the IDEs today are frameworks outfitted with plugins for specific languages and tasks, rather than apps written from the inside out to foster development in a given language. To that end, your choice of IDE may be determined by whether or not you have experience with another IDE from the same family.
For those who don't have such experience, PyCharm is one of the best places to start. It's friendly to newcomers, but not hamstrung in its feature set. In fact, it sports some of the most useful features among all of the IDEs profiled here. Many of those features are available only in the for-pay version of the product, but there is plenty in the free version to help a fledgling developer get started.
LiClipse and the Python Tools for Visual Studio (PTVS) are good choices for developers already intimately familiar with Eclipse and Microsoft Visual Studio, respectively. Both are full-blown development environments -- as full-blown as you're going to find -- that integrate Python quite nicely. However, they're also sprawling, complex applications that come with a lot of cognitive overhead. If you've already mastered either of them, you'll find it a great choice for Python work.
The Python incarnation of ActiveState's Komodo IDE is a natural for those who have already used the Komodo IDE for some other language, and it has unique features (like the regular expression evaluator) that ought to broaden its appeal. Komodo deserves a close look from novices and experts alike.
Spyder is best suited to working with IPython or the other scientific-computing tools in distributions like Anaconda, rather than as a development platform for Python generally. Finally, IDLE is best reserved for quick-and-dirty scripting, and even on that count, it might take a backseat to a standalone code editor with a Python syntax plugin. That said, IDLE is always there when you need it.
IDLE, the development environment included with most every installation of Python, could be considered the default Python IDE. However, IDLE is by no means a substitute for a full-blown IDE; it's more like a fancy file editor. Still, IDLE remains one of the default options for Python developers to get a leg up with the language, and it has improved incrementally with each release of Python, especially with Python 3.5. (See this page for interesting discussion of the recent efforts to improve IDLE.)
IDLE is built entirely with components that ship with a default installation of Python. Aside from the CPython interpreter itself, this includes the Tkinter interface toolkit. One boon of building IDLE this way: It runs cross-platform with a consistent set of behaviors. As a downside, the interface can be terribly slow. Printing large amounts of text from a script into the console, for instance, is many orders of magnitude slower than if the script is run directly from the command line.
IDLE has a few immediate conveniences. It sports a built-in read-eval-print loop (REPL), or interactive console, for Python. In fact, this interactive shell is the first item presented to the user when IDLE is launched, rather than an empty editor. IDLE also includes a few tools found in other IDEs, such as providing suggestions for keywords or variables when you hit Ctrl-Space, and an integrated debugger. But the implementations for most of these features are primitive compared to other IDEs and hidebound by Tkinter's limited selection of UI components. And the collection of third-party add-ons available for IDLE (one such project is IdleX) is nowhere near as rich as you'll find with other IDEs.
In sum, IDLE is best for two scenarios. The first is when you want to hack together a quick Python script, and you need a preconfigured environment to do so. The second is for beginners who are just getting their legs. Even beginners will quickly need to graduate to a more robust option.
IDLE's main advantage is that it comes packaged with CPython, so it's useful for quick-and-dirty work or as an introduction to beginners. But it's quickly outgrown.
Spyder is short for "Scientific PYthon Development EnviRonment." It's intended for use as a workbench for scientific computing with Python, and that's reflected in the feature set, the packaging, and the overall behavior of the IDE. Spyder has useful features for general Python development, but unless you work mainly with IPython and scientific computing packages, you're probably better off with a different IDE.
The biggest reason not to use Spyder as a general-purpose Python development environment isn't the feature set, but the setup process. Spyder is not delivered as a standalone executable in the manner of a product like Visual Studio or PyCharm. Instead, it's installed as a Python package. Your easiest path to Spyder is to install a Python distribution that comes with it preloaded, such as Continuum Analytics's Anaconda.
1. Available as extension, but supports only syntax checking. 2. Available as Eclipse add-on. 3. Available in commercial version. 4. See integration instructions. 5. Uses version control systems installed on host.
Spyder includes IPython, which is a replacement for the conventional Python console. When you type commands into IPython, the results can be interactively explored. Each command can be treated as a "cell," or a segment of code that can have its output stored and collated.
Spyder adds to this by integrating cell behaviors into its code editor. If you insert specially formatted comments into any Python script, you can divide it into cells and execute those cells in the IPython interface in any order. This way, it's easy to use Spyder to prototype cells for placement into an IPython notebook later on.
For debugging, Spyder uses Python's built-in Pdb debugger. The command-line interface for Pdb is a far cry from the more sophisticated graphical debuggers found in PyCharm or LiClipse, although you can install the Winpdb graphical debugger as an optional add-on. Unfortunately, you can't use Winpdb with Python 3, as it has dependencies on packages that are still only available in Python 2 (specifically, wxPython). To that end, most people will be stuck with Pdb.
Spyder is also limited compared to other IDEs in its integration with version control systems like Git and Mercurial. If you're working in an initialized project repository, files in that project will show right-click context menu items for the repository. That said, there's no version control mechanisms built directly into Spyder; you need to have the appropriate version control application already installed on a system level, with its executables available from the system path. Spyder doesn't include tools for managing repositories in its UI, either. These shortcomings aren't so bad if you're already in the habit of managing repositories yourself, but they amount to additional hurdles if you're not.
Spyder does have useful features for general Python development. One that immediately caught my eye is the variable explorer pane in Spyder's interface. As you type commands into IPython, any variables created are logged there and can be explored interactively. Another useful tool is the User Module Deleter. Enable it and the Python interpreter will reload all modules from scratch when it executes a Python script. This way, any changes made to a module's code can be applied to a running program without having to restart the whole application.
Spyder's toolset is not as advanced as that of some other IDEs here, but its variable explorer and IPython integration are useful for data science work.
ActiveState Komodo IDE
ActiveState's line of IDE products includes versions for nearly every major language. The company's approach to this is a little like how LiClipse works: Take the basic product (in this case the Komodo IDE) and outfit it with add-ons for Python development.
Komodo is best suited to those who are already familiar with incarnations of Komodo for other languages. People with such experience under their belts will have no trouble diving into the Python product. If you're coming in cold, there are some UI quirks worth noting. For instance, the app menu bar isn't exposed by default; you have to click on the hamburger menu at the top right or tap the Alt key to show it. It's meant to keep matters clean and simple, but may be too minimalist for some tastes.
On the other hand, some of the interface choices are immediately appealing. I particularly liked the "minimap," a zoomed-out preview of the code in the editor, that lets you leap at a glance to any part of the file you're editing. LiClipse has a similar feature, but Komodo's implementation is easier to work with.
Most Python IDEs are outfitted with the likes of Python-specific syntax checking or code linting. Komodo IDE has all that, but it's also been designed to support versions 2 and 3 of the language at the same time. If you want to launch a Python shell, for instance, and you have interpreters for both versions of Python available in your system path, you can explicitly choose either version. I've often needed to run quick tests of the behaviors of a given statement in Python 2 and Python 3 side-by-side, and this is a handy way to do so.
Komodo provides you with an option to apply multiple run or debug configurations for an application, but it's a little less flexible than a similar feature in LiClipse. When you launch an app, you're given a choice of profiles to apply to the program. You can disable the profile chooser and jump straight into running a profile, but the disabling can only be done on an applicationwide basis, not for a particular project. I prefer LiClipse's toolbar dropdown menu from which you can select a given profile or launch the most recently used profile with a click.
One truly wonderful inclusion is a regular expression toolkit. Type a regular expression in one pane of this tool, provide some sample data to apply it to in a second pane, and the results appear in a third. The tool also supports multiple flavors of regex, Python included, and even shows you the results of match, split, and replace operations. I struggle all the time with crafting working regexes, so this tool is a godsend.
Another useful out-of-the-box feature is a catalog of common code snippets for Python. Click on "walk," for instance, and the editor inserts the boilerplate code to use Python's
os.walk function to traverse directories, one of the functions whose syntax and usage I can never remember offhand. Other languages are included, too. For instance, if you need to slip standard-issue HTML into a Django template you're cooking up, Komodo has you covered.
The default Python distribution comes with support for SQLite out of the box. Komodo IDE complements this by providing a built-in explorer for SQLite databases. It's sort of like a stripped-down version of the "workbench" desktop apps provided for MySQL or Microsoft SQL Server. The interface is clunky and unappealing, but it's perfectly suitable for quick-and-dirty inspection or spot editing of a database. It's not intended to serve as a full-blown database IDE.
You'll find many other useful features in Komodo, even if they don't specifically target Python. The macro recorder allows you to record and play back common actions, although it doesn't seem to record some types of actions such as choosing which app profile to use when launching an app. Another feature allows real-time collaboration between Komodo users, though they'll need to sign up for accounts with ActiveState to access the service.
Komodo's UI may take some getting used to if you're coming from another IDE, but the collection of tools is impressive.
The Eclipse IDE is often criticized as slow and overloaded, but its broad language support and gallery of development add-ons make it a powerful and valuable tool. Python is supported in Eclipse via the PyDev add-on. If you're using Eclipse for nothing other than Python development, your best bet is to grab LiClipse. (Throughout this review, I'll be using LiClipse as shorthand for the bundle of features provided by LiClipse and PyDev together.)
LiClipse is a repackaging of Eclipse with PyDev, along with a slew of other Eclipse components meant to enhance the user experience. When launched, LiClipse looks and behaves much like the regular edition of Eclipse, barring the LiClipse branding and icons, so experienced Eclipse users shouldn't have much trouble configuring the workspace to their liking. If you're not experienced with Eclipse, you will need some time to learn how Eclipse's workspace operates (this aspect of Eclipse is routinely criticized). In that sense, LiClipse is best for people who are already comfortable with Eclipse, perhaps from working in it through another language.
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.
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.
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.
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
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.
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.