What is the easiest way to uninstall all the packages that are installed?
I want to reset all of the installed libraries back to the ones that match production because I'm trying to fix up one of my virtualenvs.
This is an alternative solution that I have found.Remaking the virtualenv is more graceful than removing libraries.
If you have packages installed via VCS, you need to manually remove those lines.
All Mac, Windows, and Linux systems will work with this.If you don't want to replace old requirements.txt, give a different file name in the all following command.
If you're working on an existing project that has a requirements.txt file, you can simply replace it with a different one.The requirements.txt can be used to update your environment once you have gone through the steps above.
This answer is one of the most elegant solutions in the thread and I wanted to elevate it out of a comment section.The full credit for this answer goes to the person who wrote it.
For the use case of clearing my user packages folder outside the context of a virtualenv which many of the above answers don't handle, this worked great for me.
The other answers must include --local and uninstall packages that are found in the common namespaces.
This isn't completely solid as you may run into issues such as 'File not found' but it may work in some cases.
Unins is an arbitrary file which has data written out to it when this command executes.
The file that was written in turn is used to uninstall the aforementioned packages.
If you make a mistake, you always have a pip requirements file to fall back on.It is also repeated.
The easiest way to remake the virtualenv is completely.I'm assuming you have a requirements.txt file that matches production.
The packages are listed in the requirements file.This option can be used many times.
I don't have enough reputation to comment on the answer.
The answer works, but fails if there is no package to uninstall, which can be a problem if this is part of a script or makefile.This can be solved using xargs -r.
Do not run the command if the standard input is blank.If there is no input, the command is usually run once.This option is an extension of the Linux operating system.
One might have to run this command several times to get an empty freeze.
If you don't know where your virtual env is, you can run which python from within it to get the path.
The command uninstall -y won't work in Command Shell of Windows.I've found an alternative way to do it for those of you using Windows.
In my case, I accidentally installed a number of packages on my Macbook.The easiest way to get back to the default packages was.
I wanted to remove all the packages installed by the project, not just the ones I use for local development.I did.
Pip doesn't have a way of knowing what packages were installed by your system's package manager.You have to do something like this for this.
The top answer will remove all, so it was very misleading.If you have python packages in your distribution, you will probably have a broken system.