How do I remove pyenv virtualenvs

Viewed 15521

How do I go about removing all these virtual environments? I don't know where the directories are

2 Answers

Assuming that list came from running pyenv virtualenvs, you should be able to run

pyenv uninstall 3.8.2/envs/greenhouse

to remove the 3.8.2/envs/greenhouse environment.

The environments themselves should be subdirectories of whatever pyenv root returns when you run it. Try doing cd $(pyenv root) and then looking in the versions/ and versions/{version}/envs/ subdirectories.

See the documentation for more details.

Adding to Chris's answer, you might also need to delete the local .python-version:

$ pyenv uninstall 3.8.12/envs/test_venv 
pyenv-virtualenv: remove /home/user1/.pyenv/versions/3.8.12/envs/test_venv? (y/N) y
$ python -V
pyenv: version 'test_venv' is not installed (set by /home/user1/.python-version)
$ rm .python-version 
rm: remove regular file '.python-version'? y
$ python -V
Python 3.8.12
Related