Updated March 2020.
TL;DR: Spyder is a great IDE to start. For more advanced features, choose PyCharm.
Python is a general purpose scripting language that can be used for statistical analysis, numeric work, machine learning, and much more. If you’re coming from other scientific computing environments like Matlab, Mathematica or R, you might miss having an integrated development environment (IDE). An IDE combines editing, execution, plotting, debugging, etc. into a single coherent package.
Here I evaluate 4 IDEs for scientific Python on my Ubuntu 16 laptop to see how they stack up:
- Spyder 3.3
- Atom with Hydrogen 2.14
- VSCode 1.42
- PyCharm 2019.3.3
These IDEs combine a text editor, an integrated ipython shell or jupyter kernel integration, support for interactive plotting via matplotlib as well as several other features to tie everything together.
Criteria for evaluation
I’m a computational neuroscientist, and I work on different kinds of scientific workloads in Python, like computing summary statistics, visualization, ETL, machine learning. I was also a data scientist at Google and a BCI engineer at Facebook for a number of years. There, I also used Python on a day-to-day basis. This review is colored by these experiences. What I care about is:
- A kick-ass text editor with:
- good autocomplete
- introspection of variables and Go To Definition integration
- discoverability of features
- Support for other formats, e.g. csv, markdown, etc.
- Seamless integration of the ipython shell
- Works well for both plain-jane python and interactive cell-mode
- Bonus points for:
- seamless debugging
- git integration
I am especially interested in support for interactive cell-mode executation. In conventional, plain-jane Python, you write a big script with a .py extension that gets executed all at once – the execution environment only lasts as long as the call to Python. In interactive cell-mode, execution is split into different cells, which can be executed in any order. Jupyter notebooks use this model; many IDEs, including all of the ones I review here, now offer similar features. Interactive execution is often the environment of choice for data science, where your analysis depends on the results you learn as you go along. For this reason, I place a lot of weight on how well this core feature works.
To put these IDEs through the paces, I’ve worked on an analysis that grabs webpages through Selenium, parses and aggregates them as csvs, uses pandas to munge the data, plots many things through plotnine, and learns a model or two with sklearn.
a powerful scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts.
One of Spyder’s biggest differentiating features is that it features the ipython command line front-and-center. To execute Python code that you create in the editor, you can use any of a number of shortcuts, including:
- F9 to run a selection
- F5 to run a whole file
- Ctrl+Enter to run a code cell
- Shift+Ctrl+Enter to run a code cell and advance to the next one.
New cells are defined by
# %%. Cell execution is nearly instantaneous, and the edit-print-edit loop is very smooth. matplotlib plots show up either in a separate window or inline inside the ipython editor.
Spyder’s editor is excellent. It offers good introspection, highlights errors, gives warnings, and opens up the docstring information upon calling a function. The auto-complete is mostly good but sometimes has inexplicable misses – I haven’t quite figured out why some variables autocomplete inside the ipython command line whereas they won’t inside the editor.
The editor can find the file/line where a function was defined by holding the Ctrl button and clicking the function name. It has support for setting breakpoints within the interface, and feeds that information to the pdb debugger. pdb can then be manipulated via its command line interface inside ipython:
c to continue,
u to go up a level,
q to quit, etc. The editor also integrates help and lists all currently existing variables.
Its editor doesn’t quite stack up to modern infinitely customizable editors in terms of features. Its features are not easily discoverable because it doesn’t have a text search over commands. But honestly, this is all kind of immaterial: Spyder works. It’s polished, it’s fast, it doesn’t try to do too many things. I mean this in the nicest way possible: it’s the closest thing to RStudio or Matlab in the Python world.
- Very fast
- Ipython integration works well
- Batteries included
- Not very discoverable
- Doesn’t support many other languages apart from Python
- Dark mode still has a lot of white chrome in the window, hurts my eyes.
Total note: 4.5/5
Atom with Hydrogen
a hackable text editor for the 21st Century
It’s first and foremost a powerful text editor that, with extensions, can be used for interactive Python workloads. It supports many plugins – anything from a spell checker, git integration, Markdown rendering and even an embedded color picker (because why not?). You can install the
terminal-plus plugin to access a terminal, which will then give you a way to run Python inside the editor. To get a debugger, install
You can install the Hydrogen plugin to access to an integrated interactive cell mode for Python and all the other languages supported by jupyter. You write code separated by
# %%, press Ctrl+Alt+Enter to execute a cell, and voila! You see the results (plots, dataframes, text) inline with the code. It’s all very slick. It uses jupyter kernels behind the scene. One very neat feature is that it can use remote jupyter kernels – that means you can interact with a kernel inside the editor even if the kernel is remote. Sweet!
There’s a lot of different features you can use, which can feel a bit overwhelming at first. Thankfully, Atom has an excellent command palette:
Ctrl+Shift+P brings up a search window which allows you to search through all available commands. Type
hydrogen to see all the Hydrogen-specific commands.
Setting watches will allow you to look at the content of a variable in a separate pane. The
hydrogen-python plugin will give you a variables explorer as well. All-in-all, it’s a pretty interesting way to use Python interactively.
The one thing I find missing is a true ipython command line. If I want to see the order of execution of my code, I’m out of luck. Similarly, if I want to see the help for a command, I can’t just type
command? in a terminal – I have to create a new code cell, look at the help, and then potentially immediately delete the code cell. It’s a bit inelegant.
Although the text editor in Atom is very good, the autocomplete and the introspection is sub-par compared to three other editors here. Combine this with a fragmented ecosystem, and it’s not exactly the most user-friendly solution. Overall, although I like Atom a lot, and it’s very customizable, it’s not my top choice for interactive Python work.
- Very customizable
- Innovative cell mode
- Plugins for everything
- Easily discoverable
- Remote kernels
- Lots of things to install – not very beginner friendly
- Lackluster autocomplete and definition search
- No real ipython command line brings me great sadness
Overall score: 3.5/5
VSCode is a free text editor from Microsoft. Like Atom, it’s first and foremost a text editor with easy plugins. It has as command palette that can be pulled up with the same shortcut (Ctrl+Shift+P). Like Atom with Hydrogen, it has an interactive Python mode that uses Jupyter kernels in the background.
This interactive mode fixes a lot of the issues in Atom. The results of running cells show up in a different window, and you get access to an actual command line (🙌). The boundaries between the different cells show more prominently. Furthermore, introspection, finding definitions, and autocomplete are all a step above Atom.
However, the interactive Python mode is slow as molasses on my computer. It can take 2 seconds between hitting Ctrl+Enter and the command showing up as executed in the side window display. This is a real bummer, because vanilla VSCode itself is super fast. It’s specifically the interactive Python mode that is slow. I have a 2017 Dell XPS 13 laptop – a perfectly respectable machine, if a little outdated – and the sluggishness really gets in the way of my productivity.
I’m keeping my fingers crossed that six months down the line, the performance issues will have been fixed by MS, because I think it’s a compelling offering. In the meantime, not my top choice.
- Very customizable
- Cool split mode with Jupyter kernels
- Easily discoverable
- Plugins for everything
- Great introspection
- Emulates ipython command line
- Sluggish performance
Overall score: 3.5/5
The Python IDE for professional developpers
Unlike the three other IDEs I discussed before, this one is not free – it’s 89$US a year. If you have an academic affiliation however, you can get a free license.
PyCharm’s best feature is its autocomplete and introspection. It really is in a class of its own. When you’re learning a new language, having good autocomplete can make the difference between mediocre and acceptable productivity.
It has first-class support for Python, no plugins needed. Debugging, listing variables, git, a dedicated plot window, it’s all here. However, the interface is, in my opinion, anxiety-inducing. It’s so feature-packed that it can be hard to find the feature you want. Let’s say you want to rename a file, for instance. Forget about F2, you need to use
Refactor > Rename (Shift+F6). The shortcuts are completely different than every other piece of software I’ve used. One redeeming factor is the Command Palette,
Ctrl+Shift+A, in which you can search from hundreds of commands.
The interactive Python mode is slightly different than the last three IDEs. It does not work on .py files. Rather, it pops up when you open an ipython notebook (extension .ipynb). It then gives a split view – on one side, you see the textual representations of cells. On the right-hand side, you see the code as it might appear in Jupyter, as well as its output. It’s an interesting take on the concept. Performance is quite good; however, it sometimes slows down dramatically after a couple of hours. A restart takes care of the issue.
Overall, although PyCharm is too big for its own good, you can’t argue with the excellent introspection – the autocomplete is flawless, the inline help is very good, it will highlight subtle errors as you write your code and offer fixes, etc. The interactive cell mode is quite good – although it could use a command line. All-in-all, a great choice if you’ve started to outgrow Spyder.
- Every feature in the book
- Introspection is top-notch
- Refactoring, debugging, you name it
- Cool cell mode
- Anxiety-inducing in its complexity
- Absurd default keyboard shortcuts
- Sometimes slows down for no good reason
Overall grade: 4/5