我想使用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编译器。我正在使用安装了默认llvm的OSX 10.9,因此对添加gcc安装持谨慎态度。当llvm接管后,许多程序必须重新编译,因此再次更改默认编译器似乎很危险。
如何使Brew完成安装?有什么建议吗?