61

I have read and followed this answer to 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 synonymy of gcc, then I create a symlink

$ 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

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?

Community
  • 1
  • 1
teddy
  • 2,158
  • 4
  • 26
  • 34
  • Do you really want to compile `scipy` or is using a precompiled version as shipped with `anaconda` an option for you? – cel Apr 12 '15 at 08:02
  • 2
    gfortran command itself calls a common thing as gcc does, but then it calls the Fortran frontend and you must have it installed. Symlink gfortran → gcc is not enough. – Vladimir F Героям слава Apr 12 '15 at 08:29
  • 3
    Did you do `brew install gcc`? http://stackoverflow.com/questions/26919450/can-not-install-gfortran-via-homebrew – Vladimir F Героям слава Apr 12 '15 at 08:32
  • I went down this rabbit hole for several hours and then decided to simply install anaconda, which ships with Numpy, Scipy, Sk-learn, Pip, and lots of other great packages. I highly recommend Anaconda! – duhaime Apr 12 '15 at 12:53
  • Brew currently ships gcc version 4.9, with gfortran built by default. Did you by chance install gcc48 from homebrew/versions? In that version, fortran support must be enabled by the user. As mentioned before, the gcc-X.Y commands and gfortran are _not_ equivalent one shouldn't symlink the other. – ianml Apr 12 '15 at 19:17

6 Answers6

56

The following worked for me:

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)

Community
  • 1
  • 1
49

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

(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
teddy
  • 2,158
  • 4
  • 26
  • 34
4

For macOS, installed Fortran and it worked.

$ brew install gfortran
Grayrigel
  • 3,474
  • 5
  • 14
  • 32
1

I have the same error and use the command:

brew install gfortran

The log shows that also the GCC was installed as well and finally, I can install Scipy.

Arefe
  • 11,321
  • 18
  • 114
  • 168
0

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

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/

Manoj Sahu
  • 2,774
  • 20
  • 18
0

For Arch Linux, you'll need to install core/gcc-fortran, although I realized that I could just change the version of scipy in my requirements.txt file to the newest version available to fix the issue, too.

jenks
  • 383
  • 1
  • 3
  • 11