Review: 7 Python IDEs go to the mat

Which Python IDE is right for you? Here’s how IDLE, Komodo, LiClipse, PyCharm, Python extension for Visual Studio Code, Python Tools for Visual Studio, and Spyder stack up in capabilities and ease of use.

1 2 Page 2
Page 2 of 2

Python extension for Visual Studio Code

The explosive growth and popularity of Microsoft’s Visual Studio Code has fed development for add-ons that support just about every programming language and data format out there. VS Code’s best-known Python add-on is also developed by Microsoft, and together the editor and the add-on make for one of the best solutions available for Python development.

When installed, Microsoft’s Python extension also installs support for Jupyter notebooks, which can be opened and used directly in the editor. The Python extension also provides Pylance, a language server that provides linting and type checking by way of the Pyright tool. Together these components provide a solution that covers the vast majority of development scenarios.

One major drawback with Python extension for VS Code is the lack of a general setup process, like a wizard, for creating a new Python project and configuring all of its elements. Each step must be performed manually: creating the virtual environment, configuring paths, and so on. It also lacks full-blown integration for Python project management tools like Pipenv. It’s entirely possible to set those up by hand from the command line for a given project; there’s just no facility for using them in Python extension for VS Code. And while support for some individual frameworks exist —e.g., debug support for Django templates—those still must be configured manually.

On the plus side, VS Code automatically detects virtual environments in a project directory, and makes a best effort to use them whenever you open a terminal window in the editor. This saves the hassle of having to manually activate the environment. VS Code can also detect virtual environments created with Poetry, the Python project-management tool, although this feature was available only as a preview at the time of this writing.

Another powerful feature in VS Code, the command palette, lets you find just about any command or setting by simply typing a word or two. Prefix your search term with “Py” or “Python” and you’ll get even more focused results. And a broad variety of linters and code-formatting tools are supported natively in the Python extension.

One thing VS Code supports well with the Python extension is discovery and execution of unit testing. Both Python’s native unittest and the third-party pytest are supported. Run the “Python: Discover tests” command from the palette, and it will walk through the discovery of tests and set up a test runner button on the status bar at the bottom. Individual tests even have in-line annotations that let you re-run or debug them. It’s a model for how I wish many other things could be done with the Python extension.

The Python extension concentrates on the most broadly used parts of Python, and leaves the more esoteric corners to third parties. For instance, there is no support for the Cython superset of Python, which lets you compile Python into C. A third-party extension provides Cython syntax highlighting, but no actual integration of Cython workflow.

What’s best about the Python extension for Visual Studio Code is how it benefits from the flexibility and broad culture of extensions available for VS Code generally. Key bindings, for instance, can be freely remapped, and any number of themes are available to make VS Code’s fonts or color palettes more palatable.

vs code python IDG

Visual Studio Code’s open-ended architecture allows support for any number of languages, with Python being one of the major players.

Python Tools for Visual Studio 2019

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.

Python runtimes also can be installed automatically (Python 3.7.8 and Python 2.7.18, 32-bit or 64-bit). You can even install Miniconda, the slender version of Anaconda, for projects that need that distribution of Python. Also available are templates for Scikit-learn projects, using the cookiecutter project templating system. That said, it would be nice to see more options for other machine learning systems, like PyTorch.

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 located. Visual Studio also smartly detects the presence of requirements.txt files, and can create a virtual environment for your project with those requirements preinstalled. If you’re porting an existing project that includes virtual enviromments, they too will be automatically detected and included.

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, 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.

Python Tools for Visual Studio provides a built-in facility for running the Pylint and Mypy code analyzers. As with other Visual Studio features that depend on external packages, Visual Studio will attempt to install either of those packages if you haven’t yet set them up. You can also set up the linters by hand in your virtual environment; in fact I prefer this option because it is the most flexible.

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.

visual studio python IDG

Microsoft offers first-class support for Python as a development language in Visual Studio, including support for web frameworks.

Spyder

Most Python IDEs are general purpose, meaning they’re suitable for any kind of Python development—or for developing in other languages along with Python. Spyder focuses on providing an IDE for scientific work rather than, say, web development or command-line apps. That focus makes Spyder less flexible than the other IDEs profiled here, especially since it doesn’t have the range of immediate third-party extensibility (for instance, as Visual Studio Code has plug-ins), but it’s still quite powerful for its specific niche.

Spyder itself is written in Python. This might be its biggest quirk or its best feature, depending on how you frame it. While it makes Spyder hackable for Python developers, it also makes Spyder awkward to use as a standalone application. It’s mainly intended to be used in the Anaconda Python distribution (or the portable WinPython distro), where Anaconda provides many of the project management features that Spyder lacks.

It is possible to install Spyder standalone with an installer, but the chief drawback there is the absence of per-project configuration. This mainly means there is no easy way to configure Spyder to work with any given project’s virtual environment when you launch the project; you can only configure Spyder as a whole to work with one particular venv. At least there’s a quick link on the application status bar to change this setting.

Another approach is to create a venv and install Spyder into that, and launch Spyder from within the venv. However, this requires installing dozens of packages that total over 400MB, so might not be practical for multiple projects that require it. Another downside: Regardless of the setup method, Spyder takes much longer to launch than the other IDEs profiled here.

Spyder shines, though, in making Python’s scientific computing tools immediately available in a single interface. The left-hand side of the UI is taken up with the usual project-file-tree/editor-tab-set display. But the right-hand side features two tabbed panes devoted to visualization and interactive tools. IPython and Jupyter notebooks run in their own pane, along with generated graphical plots (which you can show inline as well, or solely in the Plots tab).

I particularly liked the variable explorer that shows you, and lets you interactively edit, all the user-created variables in your IPython session. I also liked the built-in profiler pane, which lets you see statistics on which parts of your program take the most time to run. Unfortunately, I couldn’t get the profiler to work reliably with projects in their own venv unless I installed Spyder in the venv and launched it from there.

Key bindings in Spyder are all configurable, including those for panes other than the editor (e.g., the plotting view). But here again, key bindings can only be configured on an editor-wide basis. For unit testing, you will need to install a separate module, spyder-unittest, which works with Python’s own unittest and the pytest and nose frameworks.

spyder IDG

Spyder is focused on math and science—hence its presence in the Anaconda distribution—but it can be used for other kinds of development work too.

Copyright © 2021 IDG Communications, Inc.

1 2 Page 2
Page 2 of 2