[英]Two different Python3 and Two different Python2 installations on MacOS Catalina
I have an issue, when using Visual Studio Code, and when I'm choosing the interpreter of Python to use within a code, I realize there are two different installations or Python 3, besides the two Python2 installations.我有一个问题,在使用 Visual Studio Code 时,当我选择 Python 的解释器在代码中使用时,我意识到除了两个 Python2 安装之外,还有两个不同的安装或 Python 3。
The problem comes when I'm trying to use the 'Extract Method' on the 3.8.2 and it tells me to update pip.当我尝试在 3.8.2 上使用“提取方法”时出现问题,它告诉我更新 pip。 How do I choose the installation to update pip?如何选择安装更新pip?
When I run "sudo pip install --upgrade pip" it only goes to the python 2 apple version.当我运行“sudo pip install --upgrade pip”时,它只会转到 python 2 苹果版本。 But I can't update the pip on the other installations.但我无法在其他安装上更新 pip。
Thanks in advance.提前致谢。
You can run python -m pip
to run pip
with a particular Python version.您可以运行python -m pip
以使用特定的 ZA7F5F35426B927411FC9231B53Z 版本运行pip
So所以
sudo /usr/[local/]bin/python[3] -m pip install --upgrade pip
Square brackets []
mean optional parts.方括号[]
表示可选部分。
First new version of MacOs are built in python2 and python3 in usr/bin第一个新版本的 MacOs 内置在 usr/bin 中的 python2 和 python3 中
just leave them and install newest python离开它们并安装最新的 python
then edit path which in /etc/paths put 'usr/local/bin' on the first line然后编辑在 /etc/paths 中将 'usr/local/bin' 放在第一行的路径
enjoy.请享用。 now all your python3 is run in usr/local/bin which is newest and installed by yourself.现在你所有的 python3 都在 usr/local/bin 中运行,它是最新的并由你自己安装。 Also pip is work too. pip 也可以工作。 if you wanna upgrade your python just run brew upgrade.如果你想升级你的 python 只需运行 brew upgrade 。 It's best way to use python on mac and DONT DELETE default python2 and 3 just leave them这是在 mac 上使用 python 和 DONT DELETE 默认 python2 和 3 的最佳方法,只需保留它们
As said in Upgrading pip for different versions of python , you can:如为不同版本的 python 升级 pip 中所述,您可以:
Use the python 3.8 interpreter to run the command:使用 python 3.8 解释器运行命令:
python3.8 -m pip install --upgrade pip
Or use the pip3.8 binary directly:或者直接使用 pip3.8 二进制文件:
pip3.8 install --upgrade pip
Note that if the Python command is not in your PATH, you must provide the full path when running the upgrade:请注意,如果 Python 命令不在您的 PATH 中,则必须在运行升级时提供完整路径:
/usr/local/bin/python3 install --upgrade pip
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.