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

标签 python windows pip

运行 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 name that cannot be imported, and once it has confirmed that everything will succeed (including installing new versions if it’s doing an upgrade), 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, especially for 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. I thought pip ignored them completely, but perhaps something else changed since I tested that?

The directories are safe to delete.

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

相关文章:

python - 扭曲:如果回调出错,则没有异常跟踪

Python redis.client 锁不工作

windows - Kotlin代码的运行时编译会引发RuntimeException(警告:无法为Windows初始化 native 文件系统)

linux - 安装 psycopg2 linux "x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’ 时出错”

python - 消除计算机上安装的重复 python 版本- Mac OS

python - 如何使用任何库在 python 中将 RTF 字符串转换为纯文本

python - 腐 eclipse 阵列的几层

c++ - 从 Windows 服务检测 SD 卡插入?

java - 在另一台服务器上创建文件

python - 使用 Virtualenv 在 Ubuntu 上安装 Pip NLTK 问题