Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing gfortran for numpy with homebrew

I want to install a working version of numpy using brew. brew install numpy gives the message:

==> python setup.py build --fcompiler=gnu95 install --prefix=/usr/local/Cellar/numpy/1.8.1
File "/private/tmp/numpy-ncUw/numpy-1.8.1/numpy/distutils/fcompiler/gnu.py", line 197, in get_flags_opt
v = self.get_version()
File "/private/tmp/numpy-ncUw/numpy-1.8.1/numpy/distutils/fcompiler/__init__.py", line 434, in get_version
raise CompilerNotFound()
numpy.distutils.fcompiler.CompilerNotFound

brew doctor is okay, so it may actually be a missing fortran compiler problem. Try: brew install gfortran

Error: No available formula for gfortran 

Huh. from the comments in the brew GitHub issue tracker, it looks like gfortran is no longer in brew. Let's try to download gfortran 4.9.0 from the project website and set FC=\path\to\gfortran so that brew knows to use it

==> Building with an alternative Fortran compiler
This is unsupported.
Warning: No Fortran optimization information was provided.  You may want to consider
setting FCFLAGS and FFLAGS or pass the `--default-fortran-flags` option to
`brew install` if your compiler is compatible with GCC.

If you like the default optimization level of your compiler, ignore this
warning.
==> Downloading https://downloads.sourceforge.net/project/numpy/NumPy/1.8.1/numpy-1.8.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/numpy-1.8.1.tar.gz
==> python setup.py build --fcompiler=gnu95 install --prefix=/usr/local/Cellar/numpy/1.8.1
File "/private/tmp/numpy-mrQk/numpy-1.8.1/numpy/distutils/fcompiler/gnu.py", line 197, in get_flags_opt
v = self.get_version()
File "/private/tmp/numpy-mrQk/numpy-1.8.1/numpy/distutils/fcompiler/__init__.py", line 434, in get_version
raise CompilerNotFound()
numpy.distutils.fcompiler.CompilerNotFound

Drat, so brew doesn't want to use a non-default fortran compiler. I'm using OSX 10.9 with llvm installed by default, so am wary about adding a gcc install. When llvm took over, many programs had to be re-compiled, and so changing the default compiler (again) seems dangerous.

Any advice on how to get brew to complete the installation would be very welcome.

like image 260
GnomeDePlume Avatar asked May 17 '14 16:05

GnomeDePlume


1 Answers

brew install gcc

Numpy install now works fine.

like image 108
GnomeDePlume Avatar answered Sep 30 '22 04:09

GnomeDePlume