gpt4 book ai didi

python - pip 如何删除带有前导破折号 : "-pkgname" 的错误安装包

转载 作者:行者123 更新时间:2023-12-05 07:15:51 24 4
gpt4 key购买 nike

运行 pip freeze 后,我注意到列表顶部有以下警告:

WARNING: Could not parse requirement: -atplotlib

所以我使用pip list检查了安装的包,确实以下被认为是一个包:

Package         Version
--------------- -------
-atplotlib 3.0.3

我假设我在安装/升级 matplotlib 时可能有错字,导致安装了上述“包”。

但我无法删除它,因为 pip uninstall -atplotlib 被读取为命令并返回以下错误:

No such option: -a

我找到了以下文件夹:

C:\Users\name\Anaconda3\Lib\site-packages\~atplotlib

C:\Users\name\Anaconda3\Lib\site-packages\~atplotlib-3.0.3-py3.7.egg-info

移除它们是否安全且足够?

最佳答案

从您的 site-packages 目录中删除有问题的文件夹是安全的。

更多信息如下 ( source ):

When uninstalling a package, pip will now rename it in place to a namethat cannot be imported, and once it has confirmed that everythingwill succeed (including installing new versions if it’s doing anupgrade), only then will it delete those folders. If something fails,it renames them back.

Previously, it would copy the entire contents to another directory,and potentially another drive, and then copy them back if it needed.So this change is a significant performance improvement, especiallyfor packages with a lot of files in them.

What you’re seeing here is that the deletion failed for some reason -perhaps pip crashed? - and so the directories were not removed. Ithought pip ignored them completely, but perhaps something elsechanged since I tested that?

The directories are safe to delete.

关于python - pip 如何删除带有前导破折号 : "-pkgname" 的错误安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59457069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com