[英]How to install pip in Python 2.7 on macOS Big Sur?
I'm trying to install pip via我正在尝试通过安装 pip
sudo -H python -m pip install -U pip
but this results in the following error.但这会导致以下错误。
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "/Library/Python/2.7/site-packages/pip-21.1.2-py2.7.egg/pip/__init__.py", line 1, in <module>
from typing import List, Optional
ImportError: No module named typing
According to phd's solution根据博士的解决方案
The later versions require Python 3.6+.更高版本需要 Python 3.6+。 The syntax f"" is supported by Python 3.6+.
Python 3.6+ 支持语法 f""。
To install pip for Python 2.7 install it from https://bootstrap.pypa.io/pip/2.7/ :要为 Python 2.7 安装 pip,请从https://bootstrap.pypa.io/pip/2.7/安装它:
- curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
- python get-pip.py
- python -m pip install --upgrade "pip < 21.0"
The last command is to upgrade to the latest supported version.最后一个命令是升级到最新支持的版本。 For Python 2.7 the latest supported is currently pip 20.3.4.
对于 Python 2.7,当前支持的最新版本是 pip 20.3.4。
For Python 3.4 install from https://bootstrap.pypa.io/pip/3.4/ .对于 Python 3.4 从https://bootstrap.pypa.io/pip/3.4/安装。 For Python 3.5 — https://bootstrap.pypa.io/pip/3.5/ .
对于 Python 3.5 — https://bootstrap.pypa.io/pip/3.5/ 。
For Python 3.4 the upgrade command is对于 Python 3.4,升级命令是
- python -m pip install --upgrade "pip < 21.1.2"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.