pyvenv icon indicating copy to clipboard operation
pyvenv copied to clipboard

Basic usage/setup

Open garyo opened this issue 7 years ago • 6 comments

If I have a project with a venv (local in that dir), what's the best-practices way to configure pyvenv? I assume I need a .dir-locals.el in the project root, something like this:

((python-mode . ((eval . (pyvenv-activate "venv")))))

but how to also enable pyvenv-mode and maybe pyvenv-tracking-mode? Should I set those up in a python mode hook globally in my .emacs?

It might be useful to have a more complete setup recipe in the README.

garyo avatar Jun 13 '18 14:06 garyo

The best practice for using pyvenv is to stick to the best practice set up with virtualenvwrapper, i.e. do not put your virtualenvs into the same directory as your project but keep them in a ~/.virtualenvs/ directory. If you use virtualenvwrapper in your shell, pyvenv should work by default exactly like in the shell using M-x pyvenv-workon instead of workon.

jorgenschaefer avatar Jun 15 '18 09:06 jorgenschaefer

@jorgenschaefer Can you elaborate? My virtualenv happens to be in the directory, not in ~/.virtualenvs/. How can I tell pyvenv where my virtualenv is?

sid-kap avatar Jul 05 '18 21:07 sid-kap

If you do not use the normal virtualenvwrapper setup, you can use M-x pyvenv-activate like you'd use the activate script of a virtualenv.

jorgenschaefer avatar Jul 06 '18 11:07 jorgenschaefer

I mean, if I want it to remember which venv to use for my directly? Since that's what this thread is about

sid-kap avatar Jul 08 '18 03:07 sid-kap

You can use pyvenv-tracking-mode and set pyvenv-workon or pavenv-activate in the respective buffer? I usually don't, because switching virtualenvs takes time, so I juse use pyvenv-workon manually.

jorgenschaefer avatar Jul 20 '18 09:07 jorgenschaefer