Cannot uninstall 'pyparsing'. It is a distutils installed project

我的环境:

[root@ansible ~]# python -V
Python 2.7.5
[root@ansible ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@ansible ~]# pip -V
pip 20.2.2 from /usr/lib/python2.7/site-packages/pip (python 2.7)
[root@ansible ~]#

安装 jupyter 时报错如下:

pip install jupyter
...
Collecting pyparsing>=2.0.2
  Downloading http://pypi.doubanio.com/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
     |████████████████████████████████| 67 kB 4.7 MB/s
Requirement already satisfied: contextlib2; python_version < "3" in /usr/lib/python2.7/site-packages (from importlib-metadata; python_version < "3.8"->jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (0.6.0.post1)
Requirement already satisfied: zipp>=0.5 in /usr/lib/python2.7/site-packages (from importlib-metadata; python_version < "3.8"->jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter) (1.2.0)
Using legacy 'setup.py install' for pandocfilters, since package 'wheel' is not installed.
Installing collected packages: pyparsing, packaging, bleach, pandocfilters, testpath, nbconvert, terminado, notebook, widgetsnbextension, ipywidgets, jupyter-console, jupyter
  Attempting uninstall: pyparsing
    Found existing installation: pyparsing 1.5.6
ERROR: 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.

解决办法,手动升级 pyparsing 版本之后再次运行 pip install jupyter,安装成功。

pip install -I pyparsing==2.2.0
Successfully installed pyparsing-2.2.0
[root@ansible ~]# pip install jupyter
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your P                                                                                                                                              ython as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in Janua                                                                                                                                              ry 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/late                                                                                                                                              st/development/release-process/#python-2-support
Looking in indexes: http://pypi.douban.com/simple
...
Successfully installed bleach-3.1.5 ipywidgets-7.5.1 jupyter-1.0.0 jupyter-console-5.2.0 nbconvert-5.6.1 notebook-5.7.10 packaging-20.4 pandocfilters-1.4.2 terminado-0.8.3 testpath-0.4.4 widgetsnbextension-3.5.1```

参考文章

解决 Cannot uninstall 'pyparsing' 问题
https://www.cnblogs.com/qq952693358/p/10246375.html

原文地址:https://www.cnblogs.com/chenjo/p/13593626.html