簡體   English   中英

當其中一些軟件包是通過 sudo pip3 安裝其他軟件包時,如何刪除 pip 安裝的所有軟件包

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

我是 python 的新手,當我通過 pip3 安裝軟件包時,我搞砸了“sudo pip3”和“pip3”(當時我不知道區別)。 最近想把之前安裝的包全部刪除,試過了

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

我得到

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

比我試圖用 -H 標志添加 sudo

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

這次我得到了很多沒有卸載的軟件包

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
.
.
.

我不知道發生了什么,需要一些幫助

如果您使用 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