How do I remove pyenv virtualenvs

69.6k Views Asked by At

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

3

There are 3 best solutions below

0
Chris On

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.

0
natskvi On

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
0
lloyd-dotmodus On

You can also use: pyenv virtualenv-delete <venv-name> - Delete Virtual Environment