I use elpy with:

(setq python-shell-interpreter "/usr/bin/python3")
(setq elpy-rpc-backend "jedi")

I need now to work on a virtuaelnv. If I start it in a terminal and then edit the source code with emacs, elpy does not pick up the virtualnev.

Looking at the documentation I'm confused: do I need pyenv (and pyenv-mode?) or anything else?

  • If it hasn't changed in the last month, you need it. I can recommend pyvenv.
    – bertfred
    Jan 5 '18 at 13:19

To work on a virtual environment, you need to call M-x pyvenv-workon and then select the preferred working environment.

There is no need to install other packages as elpy comes with pyvenv package.


In the end the solution for me was:

  1. install virtualenvwrapper

  2. create virtualen

  3. run pyvenv-workon and select the desired environment.


  1. make sure that emacs sees the correct workon dir: (getenv "WORKON_HOME") (read from ~/.profile)

  2. make sure that the virtualenv python (/bin inside the virtualenv dir) is the same you see in emacs (inspect with M-x elpy-config (both for RPC Python and Interactive Python options)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.