paint-brush
Setting up Atom as a Python IDE [A How To Guide] by@DavidDataScience
97,667 reads
97,667 reads

Setting up Atom as a Python IDE [A How To Guide]

by DavidFebruary 13th, 2020
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

Setting up Atom as a Python IDE [A How To Guide] The guide shows how you can setup and maintain a python friendly development environment from within Atom. In a separate article I (will) show how to setup Microsoft Visual Studio Code in a similar manner. The guide is tested and valid for the latest version of Atom 1.40-40-Python 3. (It may work for earlier versions of Atom, but untested.) The guide includes a Linter Package (Source Code Checker) and a Script Package.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Setting up Atom as a Python IDE [A How To Guide]
David HackerNoon profile picture

In this article, I demonstrate how you can setup and maintain a python friendly development environment from within Atom.  Ideally, a developer wants to reduce the amount of window/application switching as much as possible and create repeatable workflows. 

Contrary to the above parody cartoon, Atom is a respectable editor and keybinding plugins are available for those of us that grew up with Emacs and Vim so that we can have a mouse-free coding experience.Atom was developed initially from with Github, but by it’s open-source and extensible nature, a strong community that provides support and additional plugin functionality, it has become a very powerful – but free – tool for development.I use Atom primarily for Python, Julia, shell script and web-development. In a separate article I (will) show how to setup Microsoft Visual Studio Code in a similar manner.  Code is also open-source, free, and supported by a large community, and it has advantages if you also code for various compilers and proprietary databases. 

Note: Towards the end of this article I discuss how you can automate the saving of a list of all of your plugins so that you can reinstall them as a group later, keep in a code repository, or migrate to a new development machine.  Myself, I keep my configuration in the cloud, so I can continue to work at a client location with a predictable setup.

These instructions are tested and valid for

Atom 1.40
and
Python 3
and up. (It may work for earlier versions of Atom, but untested.)

Steps:

1. Download Atom

“Atom is a free and open-source text and source code editor for macOS, Linux, and Microsoft Windows with support for plug-ins written in Node.js, and embedded Git Control, developed by GitHub. Atom is a desktop application built using web technologies.”

You can use Atom's UI to install the plug-ins listed below using Atom's Settings View: just type

ctrl +
(on Linux or a PC), and 
cmd +
(on a Mac).

Alternatively to bring up the Settings View, you can click on the Install tab, and type the package name you want to install into the Search packages search box.

For the rest of us who actually like to use the terminal window, I provide shell commands below.

2.   Download a Linter Package (Source Code Checker)

“Linter is a base linter provider for the hackable Atom Editor. Additionally, you need to install a specific linter for your language. You will find a full list on .It provides a top-level API to its consumer so that they can visualize errors and other types of messages with ease.”

or, on the command line:
$ apm install linter
Now we also need to download a language specific linter plugin (I like flake8, but there are choices listed on the atomlinter.github.io page as above:

or, on the command line:To use this plugin flake8 will need to be installed on your system. If it is not already installed, you can install  by typing the following in a terminal:
$ pip install flake8
$ apm install linter-flake8

3. Download a Python AutoComplete Package and AutoFormatter

“Python completions for packages, variables, methods, functions, with their arguments. Powered by your choice of Jedi or Kite.”  Jedi is a locally based library, and thus I myself prefer that one over Kite, which requires an online library.

or, on the command line:
$ apm install autocomplete-python
“Uses autopep8 installed to format python code according to pep8 guidelines”

or, on the command line:
$ pip install autopep8
$ apm install python-autopep8

4. Download a Script Package

“Run scripts based on file name, a selection of code, or by line number.” This is super useful for testing your code from within Atom instead of going to a different terminal window, and it is powerful because it is selection-based, which means you can run snippets versus whole files.

or, on the command line:
$ apm install script

5. Download a File-Icons Package

“File icons similar to the vscode-icons pack for Visual Studio Code (//github.com/vscode-icons/vscode-icons) and built off of the logo-file-icons pack (//atom.io/packages/logo-file-icons) with tweaks and
additions.  Tree view ui tweeks to closer match that of visual studio code.” 

As I tend to use both Visual Studio Code and Atom, this helps me maintain consistency, and I like them better than the Atom defaults.

or, from the command line:
$ apm install atom-file-icons

6.   Download a Syntax Highlighting Theme

“A syntax theme for . Inspired by Mattia Astorino's  .“

or, from the command line:
$ apm install atom-material-syntax

7. Download and Install Minimap

The  package displays a Minimap preview of your file on the right hand side of your editor.  The minimap-git-diff and minimap-highlight-selected plugins are also useful.



or, from the command line:

$ apm install minimap
$ apm install minimap-git-diff 
$ apm install minimap-highlight-selected 

8.   Download and install a Jupyter Notebook Plugin

“A package that works like the Jupyter Notebook, but inside Atom. It's registered as an opener for .ipynb files — try opening one!"

or, from the command line:
$ pip install jupyter jupyter_kernel_gateway
$ apm install jupyter-notebook

Alternatively, you can look at the Hydrogen package:

Hydrogen runs code interactively, allows you to inspect data, and plot. All the power of Jupyter kernels, inside your favorite text editor. It supports Python, R, JavaScript and .

Checkout the  and  to see what you can do with Hydrogen.

9. Improve version control support for Atom

Because I work for several clients, I am often switching between Github, gitlab and Bitbucket for different repositories. Please look search for the following at :
  • git-control
  • git-plus
  • git-blame
  • git-time-machine
  • gitlab
  • open-on-bitbucket

10. Using version control (or cloud drives) for configuration portability

Use to version control your Atom config file, and any other config files that you may have.

Linux:

~/.atom/config.cson

Windows:

%USERPROFILE%\.atom\config.cson
  [or commonly]
C:\Users\{name}\AppData\Local\atom\config.cson
You can then host and clone your Git repository on Github, gitlab, Bitbucket, etc., and retrieve it on other computers simply by running:
$ git clone //github.com/{username}/{repo}
As with any other source-control repository, you can then keep it up to date (to upload changes) and (to download changes).

git push
and
git pull

As mentioned in the note at the beginning of the article, in order to track a common list of installed packages, at the terminal shell execute:
$ apm list --installed --bare > ~/.atom/package.list
And then add that file to you source-controlled Git repository also. To install the packages automatically back into a fresh installation of Atom:
$ apm install --packages-file ~/.atom/package.list

An example of my

package.list
file is as below:

Conclusion

In this article, I demonstrated how you can setup and maintain a python friendly development environment from with Atom ().  As a developer who wants to reduce the amount of window/application switching as much as possible and create repeatable workflows, I hope that you find this equally useful. I look forward to your comments and suggestions for improvements!
@DavidDataScience

Agree or disagree with some of the ideas presented in this article?

Looking for more coding articles? Subscribe to our newsletter in the footer below!

바카라사이트 바카라사이트 온라인바카라