elpy
elpy copied to clipboard
`pyvenv-workon` does not automatically set Python interpreter correctly
Summary
After creating a python virtual environment with python3 -m venv <some-name>
in ~/.vritualenvs
and then invoking M-x pyvenv-workon <some-name>
I find from M-x elpy-config
that Virtualenv
is set correctly however Interactive Python
and RPC virtualenv
are still set to their default path. In order to set these correctly I need to execute (setq python-shell-interpreter "python3")
every time I change to a different virtual environment. Without this C-c C-c
or C-u C-c C-c
invokes the system Python interpreter.
It would simplify usage if it is possible to set the Python interpreter provided by the virtual environment automatically.
My configuration
OS
Ubuntu 20.04 and Debian 10
Elpy configuration in my init.el
My Emacs Elpy config contains
(advice-add 'python-mode :before 'elpy-enable)
(let ((workon-home (expand-file-name "~/.virtualenvs")))
(setenv "WORKON_HOME" workon-home)
(setenv "VIRTUALENVWRAPPER_HOOK_DIR" workon-home))
(setq elpy-rpc-virtualenv-path 'current)
The problem is reproducible with an Emacs config that contains just this and nothing else.