【问题标题】:Still can't install scipy due to missing fortran compiler after brew install gcc on Mac OS X由于在 Mac OS X 上 brew install gcc 后缺少 fortran 编译器,仍然无法安装 scipy
【发布时间】:2015-06-17 15:38:12
【问题描述】:

我已阅读并关注this answer 安装 scipy/numpy/theano。但是,在 brew install gcc 之后,它仍然因缺少 Fortran 编译器的相同错误而失败。虽然 HomeBrew 安装了 gcc-4.8,但它没有安装任何 gfortran 或 g95 命令。我认为 gfortran 可能只是 gcc 的 synonymy,然后我创建了一个符号链接

$ cd /usr/local/bin
$ ln -s gcc-4.8 gfortran
$ pip install scipy

然后它检测到 gfortran 命令但仍然抱怨没有 Fortran 编译器

customize Gnu95FCompiler
Found executable /usr/local/bin/gfortran
customize NAGFCompiler
Could not locate executable f95
customize AbsoftFCompiler
Could not locate executable f90
Could not locate executable f77
customize IBMFCompiler
Could not locate executable xlf90
Could not locate executable xlf
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize GnuFCompiler
Could not locate executable g77
customize G95FCompiler
Could not locate executable g95
customize PGroupFCompiler
Could not locate executable pgfortran
don't know how to compile Fortran code on platform 'posix'
building 'dfftpack' library
error: library dfftpack has Fortran sources but no Fortran compiler found

我还应该做什么?

【问题讨论】:

  • 您真的要编译scipy 还是使用anaconda 附带的预编译版本?
  • gfortran 命令本身像 gcc 一样调用一个常见的东西,但是它调用 Fortran 前端并且您必须安装它。符号链接 gfortran → gcc 是不够的。
  • 你做了brew install gcc吗? stackoverflow.com/questions/26919450/…
  • 我在这个兔子洞里钻了几个小时,然后决定简单地安装 anaconda,它附带 Numpy、Scipy、Sk-learn、Pip 和许多其他很棒的软件包。我强烈推荐 Anaconda!
  • Brew 当前发布 gcc 版本 4.9,默认构建 gfortran。您是否偶然从 homebrew/versions 安装了 gcc48?在该版本中,用户必须启用 fortran 支持。如前所述,gcc-X.Y 命令和 gfortran not 等效,不应该对另一个进行符号链接。

标签: python macos numpy fortran homebrew


【解决方案1】:

通过升级 pip 修复,即使我刚刚在同一天重新安装了我的 pip/virtualenv。

(mypy)MAC0227: $ pip install --upgrade pip
...
(mypy)MAC0227: $ pip install theano
/Users/me/.virtualenvs/mypy/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already satisfied (use --upgrade to upgrade): theano in /Users/me/.virtualenvs/mypy/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.2 in /Users/me/.virtualenvs/mypy/lib/python2.7/site-packages (from theano)
Collecting scipy>=0.11 (from theano)
/Users/me/.virtualenvs/mypy/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading scipy-0.15.1-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (19.8MB)
    100% |████████████████████████████████| 19.8MB 23kB/s
Installing collected packages: scipy
Successfully installed scipy-0.15.1

【讨论】:

    【解决方案2】:

    以下内容对我有用:

    sudo apt-get install gfortran

    在我的系统上:

    Ubuntu 15.10(Linux 4.2.0-19-generic #23-Ubuntu x86_64 x86_64 x86_64 GNU/Linux)

    【讨论】:

    • OP 询问了 OS X。
    • 无论如何,这在 Ubuntu 上对我有用,而不是升级 pip。
    • 在 Raspberry Pi OS 64 位上为我工作
    【解决方案3】:

    对于 macOS,安装了 Fortran 并且可以正常工作。

    $ brew install gfortran
    

    【讨论】:

      【解决方案4】:

      这取决于 gcc 版本。检查您的 gcc 版本:

      Depends: gcc-4.8-base (= 4.8.2-19ubuntu1) but 4.8.4-2ubuntu1~14.04 is to be installed
      

      更新您的 gcc 版本: http://ubuntuhandbook.org/index.php/2013/08/install-gcc-4-8-via-ppa-in-ubuntu-12-04-13-04/

      【讨论】:

        【解决方案5】:

        对于 Arch Linux,您需要安装 core/gcc-fortran,尽管我意识到我也可以将我的 requirements.txt 文件中的 scipy 版本更改为可用的最新版本来解决此问题。

        【讨论】:

          【解决方案6】:

          我有同样的错误,使用命令:

          brew install gfortran
          

          日志显示也安装了 GCC,最后我可以安装 Scipy。

          【讨论】:

            猜你喜欢
            • 2012-10-24
            • 2014-10-17
            • 2019-03-26
            • 2014-07-08
            • 2012-12-30
            • 1970-01-01
            • 1970-01-01
            • 2014-03-31
            相关资源
            最近更新 更多