简体   繁体   English

尝试使用brew安装Python3

[英]Trying to install Python3 using brew

Trying to install Python3 in mac using below command : 尝试使用以下命令在mac中安装Python3:

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`

How to keep both python2 and python3 in mac without upgrading... 如何在没有升级的情况下将python2和python3保存在mac中...

Thanks! 谢谢!

The python formula is assumed by Homebrew to be Python 3. The formula python3 is thus an alias for python . Homebrew假设python公式为Python 3.因此公式python3python的别名。

You need to: 你需要:

  1. brew upgrade python , as told by the error message. brew upgrade python错误消息告诉brew upgrade python It will switch your default Homebrew Python from 2 to 3. 它会将默认的Homebrew Python从2切换到3。
  2. brew install python@2 . brew install python@2 It will install Python 2 alongside Python 3. 它将与Python 3一起安装Python 2。

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 : 但请注意,即使安装了Python 3(使用名为python的公式),命令python仍然指向Python 2.您需要输入python3来运行Python 3,或者在$PATH的开头添加Homebrew的Python 3前缀bin目录。 $PATH

export PATH="$(brew --prefix python)/libexec/bin:$PATH"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM