The Python programming environment setting involves: auto-completion, syntax checking, and virtual environments.
In order not to mess up the system, install the relevant plugin in Python's virtual environment.
First, install the Python virtual environment virtualenvwrapper
sudo apt-get virtualenvwrapper
Then create a virtual environment:
Test
Let's start with the test in this virtual environment:
First look at what packages are available:
$ pip listpip (1.5. 6 ) Setuptools (5.5. 1)
You can see only 2 packages.
The following is the beginning of installation in a virtual environment!
Second, in the virtual environment to install the relevant package Jedi, Pylint
Install
Description
Jedi---------Python auto-complete;
Pylint-------The grammar check of Python;
After installation, look at what's loaded:
$ pip Listastroid (1.3.6) Jedi (0.9.0) Logilab-common (0.63.2)Pip ( 1.5. 6 )pylint (1.4.3)setuptools (5.5. 1 )Six (1.9.0)
Third, install the relevant plug-ins in Emacs Elpy, Flycheck,Company-jedi,virtualenvwrapper
M-x package-list-packages
Installation
- Elpy
- Flycheck
- Company-jedi
- Virtualenvwrapper
Iv. Modifying the Emacs configuration file
;; add a warehouse (Require'Package )(Setq package-archives'(("GNU"."http://elpa.gnu.org/packages/") ("Melpa"."http://melpa.milkbox.net/packages/")) ) ( package-Initialize)
;; auto-complete : Company (Require'Company )(Add-hook'After-init-hook'global-company-mode); global Open(setq Company-show-numbers t); show serial number(setq Company-idle-delay0.2); menu Delay(setq Company-minimum-prefix-length1)start to complete the word count. ;; elpy---lead (Require'elpy)(elpy-enable) ;; Grammar check: Flycheck (Add-hook'After-init-hook #'global-flycheck-mode), Global open; close Flymake, using Flycheck (when (Require'flycheck Nil T)(Setq elpy-modules (DELQ'elpy-module-flymake elpy-modules))(Add-hook'Elpy-mode-hook'flycheck-mode)) ;; Virtual environment: Virtualenv Wrapper(Require'virtualenvwrapper)(venv-initialize-interactive-shells) (Venv-initialize-Eshell) (Setq venv-location"~/pyvirtualenv/"); Set the virtual environment directory;; If there are multiple directories:;; (Setq venv-location'("~/myvenv-1/";;"~/myvenv-2/"));; M-X Venv-workon Open Virtual Environment
This is the simplest Python programming environment to configure.
Note: Add the following 2 lines to the. bashrc file in your home directory
#tells Virtualenvwrapper where to store the Virtualenvs that would be created and used. Export Workon_home=~/p Yvirtualenv/usr/share/virtualenvwrapper/virtualenvwrapper. SH
pyvirtualenv is the directory where the virtual environment is placed and can be changed to the name you want. This makes the virtualenvwrapper more flexible to use.
RELATED Links: https://github.com/jorgenschaefer/elpyhttp://www.pylint.org/#myCarousel
EMACS Configuration Python Programming environment