Declaration of VAR

and some other stuff

Atom for Python development

2017-04-18 13:35:17 +0200

2017-04-18 13:35:17 +0200 | Comments

Despite the fact of being Electron-based, Atom is a really great editor, and it can be used for Python development.

I was looking for something like this, not a full-blown Java-based IDE, but merely a text editor with syntax checking and highlighting. Sublime Text is a great thing too, but for this particular purpose I liked Atom more.

So, that’s what we want to achieve:

As you can see, it not only highlights syntax, but also looks for syntax errors and provides information for whatever founded.

And now how to set all this up. I used this article, and it covers the whole process pretty nicely, but when I was using it to install the same thing at some point later, it didn’t work for me (probably because of the new linter version), so I decided to write my own article with some additions and notes.

I assume, you have already Python installed, as well as pip, and both python and pip are available in the PATH variable.

Well, install Atom itself. Make sure apm is available in your PATH variable: on Mac OS you can launch Atom and execute Atom -> Install Shell Commands; on Windows it can be found in C:\Users\YOURNAME\AppData\Local\atom\bin\.

Now open the command line and install the following packages:

apm install linter
pip install flake8
apm install linter-flake8

This should be enough, and it was, but then after updating linter to the latest version it stopped working - no warnings, no checking for errors. But installing these additional packages solved the problem:

pip install flake8-docstrings
pip install hacking

For Mac OS you might also want to add these lines into your /Users/YOURNAME/.atom/keymap.cson:

'atom-workspace atom-text-editor':
  'ctrl-backspace': 'editor:delete-to-previous-word-boundary'
  'ctrl-delete': 'editor:delete-to-next-word-boundary'

One final thing - to run your Python scripts right from Atom, install the Script package:

apm install script

Now the output of running scripts will be shown right there:



[03.06.2017] Update: Flake8 crashed

After some time, some packages got an update and something broke, so now every time I open any Python file I get this error:

Solution is to update the flake8-docstrings package:

pip install flake8-docstrings --upgrade

Now it’s back to normal.



[21.08.2017] Update: Visual Studio Code

…Or you can use Visual Studio Code, like I did after some time. It just feels faster and a bit more convenient. And also doesn’t have those infinite update cycles on Mac OS.