pyenv-virtualenv
pyenv-virtualenv copied to clipboard
Why do we need to "activate" a virtual environment?
Hi folks - Ive been playing with PyEnv and I love it so far but Im curious about something. Im starting to create virtualenvs and I see that PyEnv does that by creating symlinks under the versions directory. I get that - and it makes sense to me. But if I set a projects "local" PyEnv version to the virtual environment I just created - Im also using the PIP in that version directory. So that being said, Im already using a unique PIP package system, and the right Python version, what is the point of doing a pyenv activate
?
Am I missing something?
Thanks!
As long as you have set eval "$(pyenv virtualenv-init -)"
in your shell configuration file, you don't need to activate virtualenvs yourself. This happens automatically then.
@bartskowron Thanks for the reply. After having this conversation with a few other folks - its apparent that Im explaining myself incorrectly. Im going to work on a more thorough write up tonight and I'll post that here once it's done.
@jonlangemak I believe you mean something like "pyenv shell xxx" works just fine, why, in the case of virtualenv should we need to "activate" anything.
I'm wondering that myself.
Apparently activating calls the "activate" script provided by the virtualenv. That one would be needed if using virtualenv "alone" (independently from pyenv
). That makes sense.
Pyenv has its own mechanism to "make it work", without actually calling activate explicitely. But it seems that activate
does a few stuffs that would be needed by "scripts" that rely on it being activated.
I must say that this is all too unnecessarily confusing.
Also, what I just described (if this is correct) applies to Python virtualenv. But pyenv-virtualenv can also manage conda
environments. In that case the "activate" part is different...