pip uninstall#
pip is able to uninstall most installed packages. Known exceptions are:
Pure distutils packages installed with python setup.py install , which leave behind no metadata to determine what files were installed.
Script wrappers installed by python setup.py develop .
Options#
-r , —requirement <file> #
Uninstall all the packages listed in the given requirements file. This option can be used multiple times.
Don’t ask for confirmation of uninstall deletions.
Action if pip is run as a root user. By default, a warning message is shown.
Как удалить все библиотеки python через pip
I’m trying to fix up one of my virtualenvs — I’d like to reset all of the installed libraries back to the ones that match production.
Is there a quick and easy way to do this with pip?
30 Answers 30
I’ve found this snippet as an alternative solution. It’s a more graceful removal of libraries than remaking the virtualenv:
In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):
How To Remove all Python packages installed by pip?
How To Remove all Python packages installed by pip?
- Post author: Gankrin Team
- Post published:
This post explains – How To Remove all Python packages installed by pip. To do that lets try the below
Option 1:
Use below command –
Option 2:
If there are any packages which were installed usig VCS, then we will exclude those . And then will remove the packages
Option 3:
- Get the list of all Python pip package in the requirements.txt file – Note: This OVERWRITES the Existing requirements.txt else will create new one.
- Remove all packages – one by one
- Remove all packages at once –
Hope This post helps to explain – How To Remove all Python packages installed by pip.
How to remove all packages installed by PIP in Python
When you are developing in Python, you will probably use Python packages a lot. If you are not using virtualenv and directly developing with a local Python environment, the number of packages you installed would a lot and at some point, you might want to do some cleanup.
Note: In this demo, I’m using macOS Big Sur (11.0.1) but the method should work on any environment.
How to uninstall the package individually
To uninstall individual Python package, you need to execute the below command in the CLI.
pip uninstall [package name]
In the [package name], put the name of the package you want to uninstall.
How to uninstall all the Python packages
To uninstall all the Python packages, use the below command.
pip uninstall -y -r <(pip freeze)
Above command will uninstall all requirement file (by using -r ) and accept all (by using -y ) that is in the freeze list
As you can see the above screenshots, it will uninstall all the packages you have installed.
Please check out also How to use VirtualEnv in Python to learn more about an organized way to develop a Python app.