2

How would I activate a specific virtual environment in my init file? I know how to activate it manually, but I don't like to do it every time I start emacs.

To activate it manually I used:

pyvenv-activate

Then a path needs to be specified and it works. So I tried the following in the init file:

(pyvenv-activate PATH_TO_VENV)

Unfortunately it tells me:

Invalid function: (quote pyvenv-activate)

I want to do this, because without activating the venv, elpy does not find it and thus doesn't find jedi etc.

2

Load pyvenv first and then activate env. Add this to your init file.

(require 'pyvenv)
(pyvenv-activate "~/.virtualenvs/exp/")

If you are using virtualenvwrapper, you can use pyvenv-workon

(require 'pyvenv)
(pyvenv-workon "exp")

If you load elpy first, it will automatically load pyvenv. You don't need to do (require 'pyvenv).

  • Does it load pyvenv twice, if I still add the require statement, or does it realize, that the dependency is already fulfilled? I tend to keep the require, just in case I move it around in my init file some day… – Zelphir Kaltstahl Nov 14 '15 at 10:36
  • 1
    require checks before loading features. So it should load only once. – ChillarAnand Nov 14 '15 at 11:29

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.