Issue
I used pyenv
to create a virtualenv and activate it,
pyenv virtualenv myenv
pyenv activate myenv
then proceeded to perform a complicated and time-consuming installation of various Python packages in that virtual environment. Now I'd like to clone or duplicate or copy this virtualenv somehow, so that I can deactivate myenv
and leave it untouched while I experiment with variations. Basically, I'm looking for something like
pyenv virtualenv-copy myenv myenv-copy
which I would use in a sequence such as, for example,
pyenv deactivate
pyenv virtualenv-copy myenv myenv-copy
pyenv activate myenv-copy
but nothing like pyenv virtualenv-copy
seems to exist. What is the recommended approach for achieving this?
Solution
When you create an environment in pyenv, it stores it in the directory $(pyenv root)/versions/
Where pyenv root
is the installation area of pyenv. On Ubuntu 20.04 for me, it is /home/username/.pyenv
.
Now you can copy the env you want from the versions
and give it a new name to have an exact copy of that env. So you can do
$ cp -R (pyenv root)/versions/old_env $(pyenv root)/versions/new_env
This will create a copy of old_env
with the name new_env
.
Answered By - Ahmad Anis Answer Checked By - Senaida (WPSolving Volunteer)