【问题标题】:Installing Python3 on Mac OS X Yosemite在 Mac OS X Yosemite 上安装 Python3
【发布时间】:2015-08-26 05:20:44
【问题描述】:

我正在尝试在 Mac OS X Yosemite 上安装 Python3,并通过运行以下命令来实现:

$ brew install python3

当我尝试这样做时,我收到以下错误:

clang: error: unable to find utility "clang", not a developer tool or in PATH
otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool

我该如何解决这个问题?

谢谢。

【问题讨论】:

  • 这意味着您没有clangotool 来构建python 源代码。你有没有安装 xcode 命令行工具?
  • @kxxoling 我已经安装了整个 Xcode,可以吗?
  • 我不确定在这种情况下是否会安装 Xcode CLI。不确定时,重新安装即可。
  • 我想知道 Apple 什么时候会更新默认安装...也许几年后,到 2020 年完全不支持?

标签: python macos homebrew


【解决方案1】:

先尝试brew update,然后再尝试brew doctor。医生诊断常见问题。

您的 Xcode/命令行工具似乎有问题。 This 回答可能会有所帮助。

【讨论】:

    【解决方案2】:

    我强烈推荐使用anaconda 分发版,尤其是miniconda

    对于 OSX Yosemite,这是指向 Python 3.4 64-bit installer 的链接。

    下载应用程序后,打开终端窗口,导航到您下载应用程序的位置(例如 cd ~/Downloads)并输入:

    bash Miniconda-latest-MacOSX-x86_64.sh
    

    现在关闭并重新打开终端窗口以使更改生效。

    要测试您的安装,请从终端输入命令conda list。如果安装正确,您将看到已安装的软件包列表。

    从这里,您应该能够按照屏幕上的说明进行操作。如果迷路了,可以参考他们的installation guide

    安装conda后,需要创建环境。使用 Python 3 安装名为 py3 的新环境:

    conda create --name py3 python=3
    

    激活这个环境:

    source activate py3
    

    这里,我一般安装iPython、iPython notebook和pyqt:

    conda install ipython, ipython-notebook, pyqt
    

    现在,从您的环境中激活 ipython shell:

    ipython qtconsole
    

    虽然此回复并未尝试修复自制程序问题,但它回答了如何在 Mac OS X Yosemite 上安装 Python3 的问题。

    【讨论】:

    • 感谢您的回复。我按照说明进行操作,但是,当我输入 $ python --version 时,我得到: python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python:没有这样的文件或目录
    • 试试python3 --version。您还可以使用which pythonwhich python3 检查二进制文件的位置。我在上面扩展了我的回复。请注意,您通常在您创建的环境中使用 python。这是为了防止无意中损坏您的系统安装。
    【解决方案3】:

    打开终端并
    [尝试]:酿造更新
    [或 Homebrew 安装]:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    (代码源位于https://brew.sh/
    确保进程完成,然后 [Re-Try]:brew install python3

    【讨论】:

      【解决方案4】:

      对我来说,我跑了brew doctor,它说

      Warning: You have unlinked kegs in your Cellar.
      Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
      those kegs to fail to run properly once built. Run `brew link` on these:
        pandoc
        heroku
        numpy
        unbound
        python@3.8
      

      所以我跑了brew link python@3.8

      紧接着,python3 突然起作用了!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-19
        • 2015-12-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多