jorgenschaefer / pyvenv

Python virtual environment interface for Emacs
365 stars 57 forks source link

auto-activation of virtual env? #80

Open biocyberman opened 6 years ago

biocyberman commented 6 years ago

I usually have a env or venv directory which is created by python3 -m venv env. How do I get this virtual environment activated automatically when I open any python script under myapp and its subdirectories. Even more useful I have option set deactivate automatically virtual environment env if I navigate and open python scripts outside of myapp:

 myapp
├── src
│   ├── app.py
├── templates
│   ├── index.html
│   └── login.html
└── env
    ├── bin
    ├── include
    ├── lib
    ├── pip-selfcheck.json
    └── pyvenv.cfg
jorgenschaefer commented 6 years ago

This is not supported by default in Elpy.

You can use .dir-locals.el to specify the virtualenv for pyvenv-tracking-mode. Alternatively, you can look at the definition of pyvenv-tracking-mode to get some inspiration on how to do this in your init.el without adding new files to your project (or .gitignore).

Does this help?

biocyberman commented 6 years ago

Thanks I will check that out.

captain-kark commented 5 years ago

You can always try this https://github.com/jorgenschaefer/pyvenv/issues/51#issuecomment-474785730