在 OS X 上安装 Numba 时出错

Error installing Numba on OS X

我无法在我的 OS X 系统上安装 Numba(通过 pip)。

我正在使用

并且已经安装了先决条件(我认为)

brew install llvm
git clone https://github.com/numba/llvmlite
cd llvmlite
LLVM_CONFIG=/usr/local/opt/llvm/bin/llvm-config  python setup.py install
cd ..
rm -rf llvmlite

也尝试过

brew install llvm
brew link --force llvm  # later: brew unlink llvm
cd /usr/local/Cellar/llvm/X.X.X/include/llvm/Config/ # X.X.X = 3.6.2
ln -s llvm-config.h config.h

但我

pip install numba

给予

  Failed building wheel for llvmlite
  Running setup.py clean for llvmlite
Successfully built numba
Failed to build llvmlite
Installing collected packages: llvmlite, numba
  Running setup.py install for llvmlite ... 
  [...]        
    error: option --single-version-externally-managed not recognized

    ----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/pip-build-MY_vtC/llvmlite/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/pip-yoGGZY-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/b6/3rk65h797p7407x7d36sqn9c0000gn/T/pip-build-MY_vtC/llvmlite/

我对如何继续(没有 Conda!)感到困惑,想知道是否缺少一些简单的修复方法。

最简单的方法是安装 miniconda 而不是:

conda install numba

在 Mac(和其他平台)上完美运行。

我建议先创建一个新环境:

conda create -n my_numba_env

激活它:

source activate my_numba_env

并安装 numba:

conda install numba

以下是对我有用的方法(在 OS X 10.11.4 上使用 Homebrew Python):

brew install homebrew/versions/llvm37 --with-rtti
git clone https://github.com/numba/llvmlite
cd llvmlite
LLVM_CONFIG=/usr/local/Cellar/llvm37/3.7.1/bin/llvm-config-3.7 python setup.py install
LLVM_CONFIG=/usr/local/Cellar/llvm37/3.7.1/bin/llvm-config-3.7 pip install numba
rm -rf llvmlite

或者您可以使用自制软件:

brew install homebrew/python/numba