gpt4 book ai didi

python-2.7 - 2021 年如何在 Python 2.7 上安装 pip

转载 作者:行者123 更新时间:2023-12-04 13:08:12 26 4
gpt4 key购买 nike

我有仍在运行 Python 2.7.6 的旧生产服务器。我们有一个从 ubuntu 14.04 的 docker 镜像构建的本地环境,旨在复制该环境(一旦安装了所有东西,一切仍然可以在那里工作。)由于 PyPi 放弃了非 SNI 支持,创建此环境的打包程序构建脚本最近显然停止了工作。
我尝试使用 get-pip.py从文档下载pip:

wget -c https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2 get-pip.py
这给了我以下警告:
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.
/tmp/tmpBb3LJu/pip.zip/pip/_vendor/urllib3/util/ssl_.py:424: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
/tmp/tmpBb3LJu/pip.zip/pip/_vendor/urllib3/util/ssl_.py:164: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
ERROR: Could not find a version that satisfies the requirement pip<21.0 (from versions: none)
ERROR: No matching distribution found for pip<21.0
建议的解决方案是使用 pip升级 urllib3 https://serverfault.com/questions/866062/easy-install-and-pip-fail-with-ssl-warnings
我没有 pip 所以我使用安装了旧版本
apt-get install python-pip
这将安装 pip 1.5.4
当我尝试 pip install "urllib3[secure]"我得到以下信息:
Requirement already satisfied (use --upgrade to upgrade): urllib3[secure] in /usr/lib/python2.7/dist-packages
Installing extra requirements: 'secure'
Cleaning up...
如果我尝试 pip install "urllib3[secure]" --upgradepip install --index-url https://pypi.python.org/simple/ --upgrade pip我得到:
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement urllib3[secure] in /usr/lib/python2.7/dist-packages
Downloading/unpacking urllib3[secure]
Cleaning up...
No distributions at all found for urllib3[secure] in /usr/lib/python2.7/dist-packages
Storing debug log for failure in /root/.pip/pip.log
(pip 消息反射(reflect)的是 pip,而不是 urllib3[secure])
当我尝试使用 pip 1.5 安装 uWSGI 时
pip install uWSGI
我得到以下信息:
Downloading/unpacking uWSGI
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement uWSGI
Cleaning up...
No distributions at all found for uWSGI
Storing debug log for failure in /root/.pip/pip.log
升级 pip 在这里也不起作用
Downloading/unpacking uWSGI==2.0.18 (from -r /root/requirements.txt (line 1))
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement uWSGI==2.0.18 (from -r /root/requirements.txt (line 1))
Cleaning up...
No distributions at all found for uWSGI==2.0.18 (from -r /root/requirements.txt (line 1))
Storing debug log for failure in /root/.pip/pip.log
重新安装 pip 不起作用:
python -m pip install -U --force-reinstall pip
给我:
Downloading/unpacking pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip
Cleaning up...
No distributions at all found for pip
Storing debug log for failure in /root/.pip/pip.log
如果我打开 /root/.pip/pip.log我看到以下内容:
Downloading/unpacking pip
Getting page https://pypi.python.org/simple/pip/
Could not fetch URL https://pypi.python.org/simple/pip/: 403 Client Error: [[[!!! BREAKING CHANGE !!!]]] Support for clients that do not support Server Name Indication is temporarily disabled and will be permanently deprecated soon. See https://status.python.org/incidents/hzmjhqsdjqgb and https://github.com/pypa/pypi-support/issues/978 [[[!!! END BREAKING CHANGE !!!]]]
The link说 SNI 支持已被删除:
For users of Python 2.7.{0...8}
Upgrading to the last Python 2.7 release is an option.

However, note that Python 2.7 series itself is now End of Life and support in pip was dropped with version 21.0.

For users of Python 2.6.x and lower:
Neither the Python core developers, or pip maintainers support Python 2.6 and below.

If someone is aware of a work around for this issue (SNI support specifically) they are welcome to share it here for others.

There is no recommended solution from the PyPI team.
如何为新开发人员设置本地环境以处理我们的遗留应用程序?我已经创建了一个新的 Python 3 开发服务器和本地环境,但是我还需要一段时间才能推出临时环境和实时环境,将所有内容都移过去并进行测试。

最佳答案

正如消息所说,PyPi 有 discontinued support用于 Python <2.7.9 截至 2021 年 5 月 6 日。如果您运行的版本低于 2.7.9 并且无法升级到较新版本的 Python,那么您唯一的选择是从 PyPi 手动下载轮子.
这些是我需要对构建脚本进行的修改以使其正常工作:
我需要安装 software-properties-commongcc

apt-get install -y software-properties-common gcc
然后我下载了 (setuptools]( https://pypi.org/project/setuptools/44.1.1/#files ) 并解压并安装了它:
python ./setuptools-44.1.1/setup.py install
接下来,我下载了 pip并将其添加到名为 wheels 的文件夹中.然后我可以使用 whl 文件运行 pip 来获取 pip
python ./wheels/pip-20.3.4-py2.py3-none-any.whl/pip install --no-index --find-links ./wheels/ pip --ignore-installed
建议使用 Ubuntu 16.04 和 Python 2.7.17 构建一个 Docker 容器,并使用它来下载包。
pip download -r requirements.txt
但是软件包的版本是错误的,所以我最终通过了requirements.txt 并从 PyPi 手动下载了每个软件包。并将其添加到 wheels文件夹。正在运行的实例很有用,因此您可以运行 pip freeze或查看 requirements.txt文件以获取您需要的所有软件包的版本号。
现在我可以使用 pip,我可以安装我的其他软件包:
python pip install --no-index --find-links ./wheels/ -r /root/requirements.txt
这发现了一些我还没有下载包的依赖项,所以我不得不下载这些包并将它们添加到 wheels 中。文件夹。我发现还有一些其他东西需要与我最初下载的版本不同,一些软件包依赖于 pbr还有更多想要的 wheel :
pip install --no-index --find-links ./wheels/ pbr==5.5.1 wheel==0.36.2
我还需要下载 cMake并将其添加到 wheels文件夹
之后我可以安装我的 requirements.txt :
pip install --no-index --find-links ./wheels/ -r /root/requirements.txt --ignore-installed

关于python-2.7 - 2021 年如何在 Python 2.7 上安装 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68382662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com