使用pip在RHEL上安装matplotlib时出现错误"无法卸载'pyparsing'"

4
我正在使用RHEL7,尝试安装matplotlib。每当我尝试运行以下命令: python -m pip install -U matplotlib 或者 pip install matplotlib 我会收到错误信息:"Cannot uninstall 'pyparsing'. 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."
非常感谢您的帮助,如果您需要更多信息,请告诉我。

尝试通过 pip uninstall pyparsing 卸载 pyparsing。然后尝试安装 matplotlib - Soumendra
你是否正在使用虚拟环境来安装matplotlib?如果没有,请尝试使用。 - Soumendra
当然不是唯一的方法。 - Soumendra
1
显然,有人甚至制作了一个可能的解决方法的视频。 - ImportanceOfBeingErnest
你是否通过 yum 安装了 pyparsingyum list installed | grep -i pyparsing 返回什么?另外,Python 版本是多少 (python -V)? - hoefling
显示剩余7条评论
1个回答

4
问题在于pip无法正确卸载由“纯”distutils安装的软件包(详见此处)。
您可以通过手动删除pyparsing来解决该问题:
首先,您需要确定软件包的路径:
$ pip list -v | grep pyparsing

你会看到类似这样的内容:
pyparsing           2.0.1              /path_to_the_python/site-packages

然后按照这个 路径 删除包(注意星号):
$ rm -rf  /path_to_the_python/site-packages/pyparsing*

然后重新安装:

$ pip install pyparsing

我正在使用MacOS(Big Sur),即使使用sudo也无法删除这些文件。 - zkent

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接