尝试使用brew安装Python3 [英] Trying to install Python3 using brew
问题描述
尝试使用以下命令在Mac中安装Python3:
Trying to install Python3 in mac using below command :
brew install python3
当我运行以下错误命令时:
When i run the command getting below error :
Error: python 2.7.14_2 is already installed
To upgrade to 3.6.5, run `brew upgrade python`
如何在不升级的情况下将python2和python3保留在Mac中...
How to keep both python2 and python3 in mac without upgrading...
谢谢!
推荐答案
Homebrew假定python
公式为Python3.因此,公式python3
是python
的别名.
The python
formula is assumed by Homebrew to be Python 3. The formula python3
is thus an alias for python
.
您需要:
-
brew upgrade python
,如错误消息所示.它将默认的Homebrew Python从2切换到3. -
brew install python@2
.它将同时安装Python 2和Python 3.
brew upgrade python
, as told by the error message. It will switch your default Homebrew Python from 2 to 3.brew install python@2
. It will install Python 2 alongside Python 3.
但是请注意,即使安装了Python 3(使用称为python
的公式),命令python
仍指向Python2.您需要键入python3
来运行Python 3,或添加Homebrew的Python 3 开头的未前缀bin
目录$PATH
:
Note however that even with Python 3 installed (using the formula called python
), the command python
still points to Python 2. You need to either type python3
to run Python 3, or add Homebrew’s Python 3 unprefixed bin
directory at the beginning of your $PATH
:
export PATH="$(brew --prefix python)/libexec/bin:$PATH"
这篇关于尝试使用brew安装Python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!