How can I 'clean up' a virtualenv?
The following works for me (can be executed from any Python 3.6 virtualenv
):
virtualenv --clear your-env-name
Where your-env-name
could be:
- Path to the virtual environment (relative from current directory or absolute)
- Or if you use
virtualenv-wrapper
, just the name of the environment
To uninstall every package (including dependencies) you can freeze the requirements and then pass them to pip uninstall
:
pip freeze > to-uninstall.txt
pip uninstall -r to-uninstall.txt
This answer may be just what you need.
You can install and use the pip-autoremove utility to remove a package plus unused dependencies.
# install pip-autoremove pip install pip-autoremove # remove "somepackage" plus its dependencies: pip-autoremove somepackage -y