且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试使用brew安装Python3

更新时间:2023-01-14 22:10:43

Homebrew假定python公式为Python3.因此,公式python3python的别名.

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

您需要:

  1. brew upgrade python,如错误消息所示.它将默认的Homebrew Python从2切换到3.
  2. brew install python@2.它将同时安装Python 2和Python 3.
  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.

但是请注意,即使安装了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"