通过Homebrew安装gfortran以支持numpy
我想用brew安装一个可以用的numpy
版本。但是输入brew install numpy
后,出现了这样的提示:
==> 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
是正常的,所以可能是缺少fortran编译器的问题。可以试试:brew install gfortran
Error: No available formula for gfortran
嗯,从brew的评论中可以看到,在GitHub问题追踪器上,gfortran似乎已经不在brew里了。我们可以试着从项目网站下载gfortran 4.9.0,并设置FC=\path\to\gfortran
,这样brew就知道要使用这个了。
==> 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
可恶,brew不想使用非默认的fortran编译器。我现在用的是OSX 10.9,默认安装了llvm,所以对添加gcc有点担心。因为当llvm接管时,很多程序都需要重新编译,所以再次更改默认编译器似乎很危险。
如果有人能给我一些建议,让brew顺利完成安装,那就太好了。
1 个回答
10
在终端里输入 brew install gcc
这个命令。
现在,Numpy 的安装可以顺利进行啦。