当前位置:   article > 正文

pip更新报错 Command “python setup.py egg_info“ failed with error code 1_pip failed with error code 1

pip failed with error code 1

已解决,解决方法直接跳转到文章末尾

这个问题遇到过好几次了,尝试多种办法但都没解决,之前一次是在部署openstack时遇到,当时也是没解决。

使用linux自带到python2.7,pip版本只有6.x,需要升级pip,不能使用yum install pip,yum上的安装包太老了

  1. [root@ansible pip]# pip -V
  2. pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

 

1. pip install --upgrade pip  无效

  1. [root@ansible pip]# pip install --upgrade pip
  2. Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7ff9deb4c3d0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/pip/
  3. Collecting pip
  4. Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz (2.1MB)
  5. 100% |████████████████████████████████| 2.1MB 33.0MB/s
  6. Complete output from command python setup.py egg_info:
  7. Traceback (most recent call last):
  8. File "<string>", line 1, in <module>
  9. File "/tmp/pip-build-4qykuD/pip/setup.py", line 7
  10. def read(rel_path: str) -> str:
  11. ^
  12. SyntaxError: invalid syntax
  13. ----------------------------------------
  14. Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4qykuD/pip/
  15. You are using pip version 8.1.2, however version 23.2.1 is available.
  16. You should consider upgrading via the 'pip install --upgrade pip' command.

 

2. pip install --upgrade pip -i http://pypi.tuna.tsinghua.edu.cn/simple/    无效

提示证书有问题

  1. [root@ansible pip]# pip install --upgrade pip -i http://pypi.douban.com/simple
  2. The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
  3. Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages
  4. You are using pip version 8.1.2, however version 23.2.1 is available.
  5. You should consider upgrading via the 'pip install --upgrade pip' command.

 

3. 改源后执行pip install --upgrade pip,提示ssl有问题,排除是源的问题。 改源其实就相当于-i URL,不用尝试  无效

  1. [root@ansible pip]# cat /root/.config/pip/pip.conf
  2. [global]
  3. index-url = https://pypi.tuna.tsinghua.edu.cn/simple/

 

4. 添加参数--trusted-host pypi.tuna.tsinghua.edu.cn 无效

pip install --upgrade pip -i http://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn  又回到第一个报错。

不行,跟pip install --upgrade pip一样报错。

5. python -m pip install --upgrade pip 同个报错 无效

    python -m pip install --upgrade --force pip 同个报错 无效

6. python -m ensurepip --upgrade 未找到模块 无效

  1. [root@ansible pip]# python -m ensurepip --upgrade
  2. /usr/bin/python: No module named ensurepip

参考pip文档:https://pip.pypa.io/en/stable/installation/

 

**************************************************************************************************************

 ------------------------------------------------------有效  有效  有效-----------------------------------------------------

7. python get-pip.py 有效

Index of /pip/

  1. [root@ansible pip]# python get-pip.py
  2. python: can't open file 'get-pip.py': [Errno 2] No such file or directory
  3. [root@ansible pip]# python

get-pip.py 提示要用2.7的get-pip.py,centos自带的是2.7,下载错了

  1. [root@ansible opt]# wget https://bootstrap.pypa.io/get-pip.py
  2. [root@ansible opt]# ls
  3. frp get-pip.py k8s-prometheus-grafana-master k8s-prometheus-grafana-master.zip
  4. [root@ansible opt]# python get-pip.py
  5. ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.

有用,pip更新到20.3.4版本

  1. [root@ansible opt]# wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
  2. [root@ansible opt]# ls
  3. frp get-pip.py k8s-prometheus-grafana-master k8s-prometheus-grafana-master.zip
  4. [root@ansible opt]# python get-pip.py
  5. 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.
  6. ******
  7. Successfully installed pip-20.3.4 wheel-0.37.1
  8. [root@ansible opt]# pip -V
  9. pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)

最后测试 pip install --upgrade pip ,终于不报错了

可能对于python2的pip版本最高只到20.3.4,而pip23是适用于python3的

  1. [root@ansible opt]# pip install --upgrade pip
  2. 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.
  3. Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages (20.3.4)

测试安装模块requests

  1. [root@ansible opt]# python
  2. Python 2.7.5 (default, Oct 14 2020, 14:45:30)
  3. [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import requests
  6. Traceback (most recent call last):
  7. File "<stdin>", line 1, in <module>
  8. ImportError: No module named requests
  9. >>>
  10. [3]+ Stopped python
  11. [root@ansible opt]# pip install requests
  12. ******
  13. Successfully installed certifi-2021.10.8 chardet-4.0.0 idna-2.10 requests-2.27.1 urllib3-1.26.16
  14. [root@ansible opt]# python
  15. Python 2.7.5 (default, Oct 14 2020, 14:45:30)
  16. [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux2
  17. Type "help", "copyright", "credits" or "license" for more information.
  18. >>> import requests
  19. >>>

 ------------------------------------------------------有效  有效  有效-----------------------------------------------------

**************************************************************************************************************

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号