简体   繁体   English

当其中一些软件包是通过 sudo pip3 安装其他软件包时,如何删除 pip 安装的所有软件包

[英]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).我是 python 的新手,当我通过 pip3 安装软件包时,我搞砸了“sudo pip3”和“pip3”(当时我不知道区别)。 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比我试图用 -H 标志添加 sudo

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我不知道发生了什么,需要一些帮助

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 v10 或更高版本,则 distutils 中的软件包将不会卸载您通过 pip 安装的其余软件包,可以使用

pip freeze | xargs pip uninstall -y

pip3 freeze | xargs pip3 uninstall -y

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM