【问题标题】:Installing gfortran for numpy with homebrew使用自制软件为 numpy 安装 gfortran
【发布时间】:2014-05-17 16:04:13
【问题描述】:

我想使用 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 issue tracker 中的 cmets 来看,gfortran 似乎不再在 brew 中。让我们尝试从the project website 下载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

Drat,所以 brew 想使用非默认的 fortran 编译器。我使用的是 OSX 10.9,默认安装了 llvm,所以要小心添加 gcc 安装。当 llvm 接管时,许多程序必须重新编译,因此(再次)更改默认编译器似乎很危险。

非常欢迎任何有关如何让 brew 完成安装的建议。

【问题讨论】:

标签: python numpy fortran homebrew gfortran


【解决方案1】:

brew install gcc

Numpy 安装现在可以正常工作了。

【讨论】:

  • 对我来说看起来是正确的,但实际上我只是到这里来寻找一种方法来 brew install gfortran 没有像“所有 gcc”这样的大依赖。如果有人知道这种方式,我会赞成。 (但我还是要“brew install gcc”,只是为了在实践中解决眼前的问题。)
  • 不幸的是,不再有 gfortran 公式,因此您将无法使用 brew 获得它(即使来自版本或骨场地窖:github.com/Homebrew/homebrew/wiki/…)。可能值得将您的问题作为一个新问题打开。我猜您必须在大而方便(brew install gcc)和小而复杂(从源代码安装 gfortran)之间进行权衡。祝你好运!
  • 还有一点需要注意:brew install gcc 可能会要求您覆盖手动安装的旧 gfortran 实例。你应该这样做...brew link --overwirte gcc 如果 brew install gcc 向你抛出这个错误。它对我有用,覆盖并没有破坏任何东西
  • @Ajay:这能替换我的 HPC gfortran 吗?是否会有我需要删除的文件(由 HPC 的 gfortran 留下)?苹果的 gcc 会发生什么?我有一个related question about how to replace my HPC gfortran with Homebrew's
  • @raxacoricofallapatorius 我发布了您的问题的答案,关于更换该软件包(或解决它以确保安全)
猜你喜欢
  • 2015-01-11
  • 1970-01-01
  • 2015-11-18
  • 2021-12-13
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多