如何将 pip 升级到 pip3 并从 python 2.7 切换到 3

How to upgrade pip to pip3 and switch from python 2.7 to 3

所以我有一台 MacBook Air 运行 11.2.1 Big Sur

pip --version

returns 这个输出:

pip 20.2.1 from /Library/Python/2.7/site-packages/pip-20.2.1-py2.7.egg/pip (python 2.7)

当我在终端中输入 python 时,它会自动加载 python 2.7,而 python3 会像预期的那样加载 python 3.8.2

我想安装 PyQT5,但这个版本的 pip 不允许我这样做,我想将 pip 升级到 pip3,并在此过程中将 python 2 替换为 python 3。

你们能帮我升级我的 python 和 pip 吗?我不介意完全失去 python 或 pip 2。

对于 macOs brew install pyhton3

Use python3 interpreter to run the command:

python3 -m pip install --upgrade --force pip

-m调用指定包的__main__.py模块


Use pip3 binary directly:

pip3 install --upgrade --force pip

适用于:pip -V