运行 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/