python - 不能再用 python 2.7 安装 pip 了吗?

标签 python pip eol

我想使用与 python 2.7(但不是 3.8)兼容的 python 脚本
我需要 pip 才能使脚本正常工作,但看起来我无法再安装 pip 了?我尝试使用 get-pip.py ,但它不起作用:

user@DESKTOP-J9T7UBF
$ 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.
c:\users\user\appdata\local\temp\tmp2kztqk\pip.zip\pip\_vendor\urllib3\util\ssl_.py:387: 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

最佳答案

最新的 pip 有 dropped support for Python 2
并且您无法使用 Python 2.7 通过 get-pip.py 安装最新的 pip。
更新:在这里找到了 Python 2.7 脚本的答案
https://stackoverflow.com/a/65866547/429476

您应该升级到 Python 3。
如果您使用只有 Python2.7 的 Linux 发行版,则可以使用 Linux 包管理器。注意 - 它安装了来自上述脚本的旧版本的 Pip。

If you installed Python from a package manager on Linux, you should always install pip for that Python installation using the same source. https://pip.pypa.io/en/stable/installing/ --> https://packaging.python.org/guides/installing-using-linux-tools/

# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1883k  100 1883k    0     0  6584k      0 --:--:-- --:--:-- --:--:-- 6584k

# python get-pip.py --user

Traceback (most recent call last):
  File "get-pip.py", line 24226, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/tmp/tmpyG_UJ3/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax
# sudo apt-get install python-pip
# python -m pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

关于python - 不能再用 python 2.7 安装 pip 了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65558034/

相关文章:

python - pkg_resources.DistributionNotFound : The 'pipenv==2018.10.13' distribution was not found and is required by the application

python - 无法安装flask-mysqldb

regex - 与 $ 元字符相关的 "string-ending newline"是什么?

python - 通过 Boto 的 AWS S3 对象生命周期

python - 如何在 HDP 中的 zeppelin-spark2 中将库安装到 python

python - 是否可以重新定义子流程?

svn - 如何在 SVN 操作期间将所有行结尾转换为 CRLF、LF 或 CR

python - Plotly 热图 - Python - 添加颜色条

python - 使用 pip 安装 mecab-python3 的问题

vim:显示列表字符会更改屏幕环绕