在Mac OS X Sierra上尝试通过自制程序安装Python 3失败

时间:2018-03-04 08:03:50

标签: python macos homebrew

我尝试使用Homebrew安装Python 3和2.7,但收到错误消息我无法找到解决方案。

尝试brew update && brew install python3时出现以下错误:

Error: python 2.7.12_2 is already installed
To upgrade to 3.6.4_3, run `brew upgrade python`

我想单独留下python 2.7安装,所以我可以同时拥有Python 2& 3我的机器上可以访问,所以我很担心升级会覆盖当前的2.7安装。

我想我仍然可以使用python.org中的软件包进行干净的并排安装,但我想知道为什么我会收到这个自制错误

brew doctor显示以下包含python的警告

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
  /Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
  /Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
  /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config

Warning: Python is installed at /Library/Frameworks/Python.framework

Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.

Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
  brew install python@2 

2 个答案:

答案 0 :(得分:0)

老实说,我在自己的系统上也有,默认情况下是Python 3,如果需要的话,可以使用Python 2。使用自制程序,您可以更新默认设置,因为它希望您进行升级。这意味着当您运行python时,Python 3将作为默认值运行。

对于Python 2,请安装brew install python@2。当您想要运行Python 2时,只需在终端中运行python2即可获得它。

答案 1 :(得分:0)

通过运行brew链接和丢失的链接组件来修复断开的链接后,Python安装将运行。 这些通常不需要SUDO,它们会先链接然后在所有链接建立后运行Brew Doctor。