在Mac OS X上使用brew安装了gcc之后,仍然无法安装scipy,因为缺少Fortran编译器。

61
我已经阅读并按照这个答案的指示安装了scipy/numpy/theano。然而,在brew install gcc之后,它仍然因为缺少Fortran编译器而失败。尽管HomeBrew安装了gcc-4.8,但它没有安装任何gfortran或g95命令。我认为gfortran可能只是gcc的同义词,然后我创建了一个符号链接。
$ 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 一起提供的预编译版本是一个选项? - cel
2
gfortran 命令本身调用了一个像 gcc 一样的常见东西,但是它会调用 Fortran 前端,你必须安装它。符号链接 gfortran → gcc 是不够的。 - Vladimir F Героям слава
3
你是否执行了brew install gcc命令?参考链接:https://dev59.com/HF8d5IYBdhLWcg3wXBJe。 - Vladimir F Героям слава
您IP地址为143.198.54.68,由于运营成本限制,当前对于免费用户的使用频率限制为每个IP每72小时10次对话,如需解除限制,请点击左下角设置图标按钮(手机用户先点击左上角菜单按钮)。 - duhaime
Brew目前使用gcc版本4.9,并默认构建gfortran。你是否安装了homebrew/versions中的gcc48?在那个版本中,用户必须启用Fortran支持。正如之前提到的,gcc-X.Y命令和gfortran是不等价的,一个不能通过符号链接来代替另一个。 - ianml
6个回答

56
以下内容适用于我:
在我的系统上,Ubuntu 15.10 (Linux 4.2.0-19-generic #23-Ubuntu x86_64 x86_64 x86_64 GNU/Linux),运行以下命令: sudo apt-get install gfortran

13
OP 询问关于 OS X 的问题。 - Blaszard
6
在Ubuntu上,这对我起了作用,而不是升级pip。 - culebrón
1
在我的树莓派64位操作系统上运行良好。 - smcs

49

通过升级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

4

在 macOS 上安装了 Fortran 并且它可以正常工作。

$ brew install gfortran

1

我遇到了相同的错误,使用了以下命令:

brew install gfortran

日志显示GCC也已安装,最终我可以安装Scipy。

0

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接