BooAA
BooAA

Reputation: 183

how to remove all packages installed by pip when some of them are installed through sudo pip3 others not

I'm very newbie to python, when I was installing packages through pip3, I messed up with "sudo pip3" and "pip3" (I didn't know the difference that time). Recently I want to remove all the packages installed before, I have tried

pip3 freeze > rquirements.txt
pip3 uninstall -r requirements.txt -y

and I get

Cannot uninstall 'apturl'. It is a distutils installed project and 
thus we cannot accurately determine which files belong to it which 
would lead to only a partial uninstall

than I tried to add sudo with -H flag

sudo -H pip3 uninstall -r requirements.txt -y 

this time I get lots of packages not uninstalled

Not uninstalling apturl at /usr/lib/python3/dist-packages, outside environment /usr
Not uninstalling asn1crypto at /usr/lib/python3/dist-packages, outside environment /usr
Not uninstalling brlapi at /usr/lib/python3/dist-packages, outside environment /usr
Not uninstalling certifi at /usr/lib/python3/dist-packages, outside environment /usr
Not uninstalling chardet at /usr/lib/python3/dist-packages, outside environment /usr
Not uninstalling command-not-found at /usr/lib/python3/dist-packages, outside environment /usr
.
.
.

I have no idea what happened, need some help

Upvotes: 2

Views: 2763

Answers (1)

Yash Kumar Atri
Yash Kumar Atri

Reputation: 795

The packages that are in distutils won't uninstall if you are using pip v10 or higher for the rest of the packages that you installed via pip can be uninstalled using

pip freeze | xargs pip uninstall -y

pip3 freeze | xargs pip3 uninstall -y

Upvotes: 2

Related Questions