I just began to use pyenv to manage my python versions, and began to use the pyenv virtualenv plugin to manage my virtualenvs, and so far, I have loved it. One thing I miss however, is that with virtualenv, you could actually place virtual environments in repository directories so that your repository was a completely reproducible environment. Does anyone know of a way to choose the directory of your virtualenv in pyenv?
While the tools allow you to put your virtual environments anywhere in the system, it is not a desirable thing to do. There are two options: Have one global place for them, like ~/virtualenvs . Store them in each project's directory, like ~/git/foobar/.
There is no command for deleting your virtual environment. Simply deactivate it and rid your application of its artifacts by recursively removing it. Note that this is the same regardless of what kind of virtual environment you are using.
Short answer: You can’t, as far as I know.
It wouldn’t really work either, right? If you use pyenv virtualenv
to install a virtualenv into a repo, and you clone that repo to another machine… how would pyenv
on the new machine know to take control of the virtualenv in the repository?
Also, “you probably shouldn’t do that”. Virtualenvs are not 100% decoupled from the underlying Python installation, and aren’t really all that portable. And do you really want to litter your repositories with a bunch of easily replicated junk? The “right” way to go about things is probably to to maintain a requirements.txt
for pip — that way you can easily reproduce your development environment wherever you clone your repo.
That all said, there’s nothing stopping you from using plain old virtualenv
to create a virtualenv anywhere you like, even if you installed virtualenv
into a Python interpreter under pyenv
control. That virtualenv itself will of course not be administered by pyenv
, but you can still use it as you always did…
Here is a GitHub issue on the project tracker asking about this: https://github.com/pyenv/pyenv/issues/802
The reply by a project collaborator was:
You can just create virtualenv in any location. To use it from pyenv, create symlink to the environment in ~/.pyenv/versions
although I must say I'm not very satisfied with this solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With