How to upgrade disutils package PyYAML?

泪湿孤枕 提交于 2019-11-29 06:03:57

问题


I was trying to install chatterbot which has a dependency on PyYAML=3.12. In my Ubuntu machine installed PyYAML version is 3.11. So I used the following command to upgrade PyYAML:

sudo -H pip3 install --upgrade PyYAML

But it gives the following error:

Cannot uninstall 'PyYAML'. 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.

My pip3 version is 10.0.0.

How to resolve this?


回答1:


Try using the --ignore-installed flag:

sudo -H pip3 install --ignore-installed PyYAML

This works because to upgrade a package, pip first uninstalls the old version, then installs the new version. It is the uninstall step that fails for distutils packages. With the --ignore-installed flag, the uninstall step is skipped and the new version is simply installed on top of the old one.




回答2:


I found in this Github issue that pip 10 no longer uninstalls distutils packages. So I downgraded to pip 8.1.1. And now it works.

If anybody, who are viewing this question, knows how to uninstall or upgrade distutils package with pip 10.0.0, please let me know here. :)

(If anybody needs)
And to downgrade pip, I used the following:

sudo -H pip3 install pip==8.1.1




回答3:


Issue:

Cannot uninstall 'PyYAML'. 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.

Solution : Remove Dist Package and RUN

sudo rm -rf /usr/lib/python3/dist-packages/yaml

sudo rm -rf /usr/lib/python3/dist-packages/PyYAML-*

Removing folder from distutils works




回答4:


You can try this:

$pip install --ignore-installed PyYAML



回答5:


I personnaly had PyYAML installed on anaconda, just executing 'conda remove PyYAML' and then executing my pip command worked.



来源:https://stackoverflow.com/questions/49911550/how-to-upgrade-disutils-package-pyyaml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!