尝试使用brew安装Python3 [英] Trying to install Python3 using brew

查看:595
本文介绍了尝试使用brew安装Python3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用以下命令在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.因此,公式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"

这篇关于尝试使用brew安装Python3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆