赞
踩
近期发现pip2在升级某些模块的时候会发生一些语法错误,基础pip基础版本是8.1.2
[root@controller ~]# pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
报错如下:
[root@controller ~]# pip install -U setuptools Collecting setuptools Downloading https://files.pythonhosted.org/packages/db/e2/c0ced9ccffb61432305665c22842ea120c0f649eec47ecf2a45c596707c4/setuptools-57.4.0.tar.gz (2.1MB) 100% |████████████████████████████████| 2.2MB 409kB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "setuptools/__init__.py", line 16, in <module> import setuptools.version File "setuptools/version.py", line 1, in <module> import pkg_resources File "pkg_resources/__init__.py", line 1367 **raise SyntaxError(e) from e** ^ SyntaxError: invalid syntax ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c_nNEz/setuptools/ You are using pip version 8.1.2, however version 21.2.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command. [root@controller ~]# pip install -U pip Collecting pip Downloading https://files.pythonhosted.org/packages/83/37/3f344e392de7792748ee32e05d7dd6f867eb2166c21c8711280fb30e2128/pip-21.2.2.tar.gz (1.6MB) 100% |████████████████████████████████| 1.6MB 495kB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-vfp8qV/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-vfp8qV/pip/ You are using pip version 8.1.2, however version 21.2.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
初步怀疑pip21有较大升级,较低版本升级有可能报错。所以先手动升级到pip20,然后在升级到最新的pip21.
手动下载pip20的Python安装包 [root@controller pip-20.2.4]# wget https://files.pythonhosted.org/packages/0b/f5/be8e741434a4bf4ce5dbc235aa28ed0666178ea8986ddc10d035023744e6/pip-20.2.4.tar.gz 解压 [root@controller pip-20.2.4]# tar -xvf pip-20.2.4.tar.gz 手动安装 [root@controller pip-20.2.4]# python setup.py install 升级到最新版本 [root@controller pip-20.2.4]# pip install -U 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 341 kB/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
升级到pip20最新版本后,有一个提示:Python2的环境最高支持pip20,pip21已经不再支持python2.7
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。