Pyenv mode |
Integrate Fabián E. Gallina python.el with pyenv tool. This allow packages which already use python.el (like python-django) got pyenv virtual environments support out-of-the-box.
- Setup
PYENV_VERSION
environment variable andpython-shell-virtualenv-path
custom variable based on user input
- Override your
exec-path
- Run external shell scripts
- Manage your pyenv installation
- Deal with virtualenvwrapper
You can simply install package from Melpa:
M-x package-install RET pyenv-mode
Add following block to your emacs configuration
(pyenv-mode)
Now you are available to specify pyenv python version:
M-x pyenv-mode-set
So now when you run inferior python with:
M-x run-python
process will start inside specified python installation. You can unset current version with:
M-x pyenv-mode-unset
When you set python version with pyenv-mode
following changes happens automatically
- compile commands use proper python version and environment
- flycheck perform syntax checking according to python version you use
- anaconda-mode search completions, definitions and references in chosen environment
You can switch python version together with current project. Drop following lines into emacs init file. When use projectile switch project with C-c p p
key binding pyenv-mode
will activate environment matched project name.
(defun projectile-pyenv-mode-set ()
"Set pyenv version matching project name.
Version must be already installed."
(pyenv-mode-set (projectile-project-name)))
(add-hook 'projectile-switch-project-hook 'projectile-pyenv-mode-set)