Linux setup - dakside/pydemo GitHub Wiki

Linux

Emacs + elpy

First, make sure that you have Emacs and Python 3 installed. Go to your terminal and use these commands

[~]$ emacs --version
GNU Emacs 25.3.5
Copyright (C) 2017 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

[~]$ python3 --version
Python 3.6.3

Next, create a virtual environment to host elpy required packages

mkdir -p ~/.emacs.d/ep3
python3 -m venv ~/.emacs.d/ep3

Next, install required packages for elpy. Run the following command in the terminal

# activate the Python virtual environment for Emacs
. ~/.emacs.d/ep3/bin/activate

# Install the packages
python3 -m pip install rope jedi flake8 importmagic autopep8 yapf

Now, fire up Emacs and install elpy. Switch to scratch buffer and run

(require 'package) ;; <--- Move the cursor to the end and C-x C-e

(add-to-list 'package-archives
             '("elpy" . "https://jorgenschaefer.github.io/packages/")) ;; <-- move to the last bracket and C-x C-e again

Now press M-x and then type package-refresh-contents and then press Enter (Return key) to load the contents of the new repository. After that press M-x and then type package-install [press Enter] elpy [press Enter] to install elpy.

To activate elpy when Emacs start, edit your ~/.emacs and add these following lines

(package-initialize)
(elpy-enable)
(pyvenv-activate "/home/user/.emacs.d/ep3") ;; change user to your actual username