分类: Linux
pip升级报错:def read(rel_path: str) -> str SyntaxError: invalid syntax报错处理

CentOS7.9升级pip时报错:

pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/1f/7f/4da15e07ccd11c84c1ccc8f6e24288d5e76c99441bf80e315b33542db951/pip-23.3.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-8ikW7F/pip/setup.py", line 7
        def read(rel_path: str) -> str:
                         ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-8ikW7F/pip/
You are using pip version 8.1.2, however version 23.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

解决办法:

python -m pip install --user --upgrade pip==20.2.4
Collecting pip==20.2.4
  Downloading https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 563kB/s
Installing collected packages: pip
Successfully installed pip-8.1.2
/usr/bin/python -m pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 35.1 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.4
    Uninstalling pip-20.2.4:
      Successfully uninstalled pip-20.2.4
Successfully installed pip-20.3.4

查看版本:

pip --version
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)


相关博文:

发表新评论