How do I remove/delete a virtualenv?
Solution 1:
"The only way I can remove it seems to be:
sudo rm -rf venv
"
That's it! 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. virtualenv
, venv
, Anaconda environment, pyenv
, pipenv
are all based the same principle here.
Solution 2:
Just to echo what @skytreader had previously commented, rmvirtualenv
is a command provided by virtualenvwrapper
, not virtualenv
. Maybe you didn't have virtualenvwrapper
installed?
See VirtualEnvWrapper Command Reference for more details.
Solution 3:
Use rmvirtualenv
Remove an environment, in the $WORKON_HOME
.
Syntax:
rmvirtualenv ENVNAME
You must use deactivate before removing the current environment.
$ rmvirtualenv my_env
Reference: http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
Solution 4:
You can remove all the dependencies by recursively uninstalling all of them and then delete the venv.
Edit including Isaac Turner commentary
source venv/bin/activate
pip freeze > requirements.txt
pip uninstall -r requirements.txt -y
deactivate
rm -r venv/