6

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.

GnomeDePlume
  • 1,642
  • 2
  • 15
  • 31

1 Answers1

10

brew install gcc

Numpy install now works fine.

GnomeDePlume
  • 1,642
  • 2
  • 15
  • 31
  • Looks correct to me, but I actually just arrived here while looking for a way to brew install gfortran *without* such a big dependency as "all of gcc". If anyone knows such a way, I'll upvote it. (But I'm about to "brew install gcc" anyway, just to solve the immediate problem in practice.) – Quuxplusone Oct 04 '14 at 01:00
  • Unfortunately there is no longer a gfortran formula, so you won't be able to get it using brew (even from the versions or boneyard cellars: https://github.com/Homebrew/homebrew/wiki/Interesting-Taps-&-Branches). It's probably worth opening your issue as a new question. I'd guess that you'll have to make the trade-off between big and convenient (brew install gcc) and small but complex (install gfortran from source). Good luck! – GnomeDePlume Oct 06 '14 at 13:52
  • 1
    also a good thing to note: `brew install gcc` may ask you to overwrite an older gfortran instance that was manually installed. you should do this... `brew link --overwirte gcc` if brew install gcc throws this error at you. It did for me and the overwrite didn't break anything – Ajay Nov 13 '14 at 22:57
  • @Ajay: Will that work to *replace* my HPC gfortran? Will there be files left behind (by HPC's gfortran) that I need to delete? What happens to Apple's gcc? I have a [related question about how to replace my HPC gfortran with Homebrew's](http://stackoverflow.com/q/27906611/656912). – orome Jan 12 '15 at 16:42
  • @raxacoricofallapatorius I posted an answer to your question, about replacing that package (or working around it to be safe) – Ajay Jan 13 '15 at 18:11
  • @Ajay: Brew "cowardly refuses" to `brew link` (which requires `sudo`). – orome Jan 13 '15 at 21:04
  • @raxacoricofallapatorius It looks like you need to change the owner of the directory that brew links to. Brew wont run as sudo, and you need those permissions to change the directory. If you make yourself (who I assume is admin if you have the root pw) the owner of the directory you should not have the cowardly refusals anymore. You might still need to overwrite or move some things though – Ajay Jan 13 '15 at 21:37
  • @Ajay: Thanks, done. Seems to be working now, though taking forever. – orome Jan 13 '15 at 21:38
  • @Ajay: Far and away the most intense computation ever performed on my machine; is it supposed to be like that? – orome Jan 13 '15 at 21:46
  • @raxacoricofallapatorius if you mean the overwrite and install, yes it takes a while – Ajay Jan 13 '15 at 22:34