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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29586487/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 04:45:20  来源:igfitidea点击:

Still can't install scipy due to missing fortran compiler after brew install gcc on Mac OS X

pythonmacosnumpyfortranhomebrew

提问by teddy

I have read and followed this answerto install scipy/numpy/theano. However, it still failed on the same error of missing Fortran compiler after brew install gcc. While HomeBrew installed the gcc-4.8, it didn't install any gfortran or g95 commands. I figure gfortran may be just a synonymyof gcc, then I create a symlink

我已阅读并按照此答案安装 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

Then it detects the gfortran command but still complaining no Fortran compiler

然后它检测到 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

What else should I do?

我还应该做什么?

采纳答案by teddy

Fixed by upgrading pip, even though I just installed my pip/virtualenv the first time anew on the same day.

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

回答by Patricio Astudillo

The following worked for me:

以下对我有用:

sudo apt-get install gfortran

sudo apt-get install gfortran

on my system:

在我的系统上:

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

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

回答by Manoj Sahu

It's depends on gcc version. Check your gcc version:

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

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

Update your gcc version: http://ubuntuhandbook.org/index.php/2013/08/install-gcc-4-8-via-ppa-in-ubuntu-12-04-13-04/

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