Python 仍然可以';在Mac OS X上brew安装gcc后,由于缺少fortran编译器,无法安装scipy

Python 仍然可以';在Mac OS X上brew安装gcc后,由于缺少fortran编译器,无法安装scipy,python,macos,numpy,fortran,homebrew,Python,Macos,Numpy,Fortran,Homebrew,我已经阅读并遵循安装scipy/numpy/theano的步骤。但是,在brew安装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编译器 cu

我已经阅读并遵循安装scipy/numpy/theano的步骤。但是,在brew安装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

我还应该做什么

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

以下几点对我很有用:

sudo apt get install gfortran

在我的系统上:

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


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

Depends: gcc-4.8-base (= 4.8.2-19ubuntu1) but 4.8.4-2ubuntu1~14.04 is to be installed
更新您的gcc版本:

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

对于macOS,我安装了fortran,并且它工作正常

$ brew install gfortran

您真的想编译
scipy
吗?还是使用
anaconda
附带的预编译版本作为您的选项?gfortran命令本身调用一个常见的东西,就像gcc一样,但是它调用Fortran前端,您必须安装它。符号链接gfortran→ gcc还不够。您是否执行了
brew安装gcc
?我在这个兔子洞里呆了几个小时,然后决定简单地安装anaconda,它附带了Numpy、Scipy、Sk learn、Pip和许多其他很棒的软件包。我强烈推荐水蟒!Brew目前提供gcc版本4.9,默认情况下会生成gfortran。您是否碰巧从自制/版本安装了gcc48?在该版本中,用户必须启用fortran支持。如前所述,gcc-X.Y命令和gfortran命令并不等同。一个不应该符号链接另一个。OP询问OS X。无论如何,这在Ubuntu上对我有效,而不是升级pip。