Trying to install Python3 using brew

北战南征 提交于 2019-12-07 03:25:09

问题


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`

How to keep both python2 and python3 in mac without upgrading...

Thanks!


回答1:


The python formula is assumed by Homebrew to be Python 3. The formula python3 is thus an alias for python.

You need to:

  1. brew upgrade python, as told by the error message. It will switch your default Homebrew Python from 2 to 3.
  2. brew install python@2. It will install Python 2 alongside Python 3.

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"


来源:https://stackoverflow.com/questions/49672642/trying-to-install-python3-using-brew

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!