在macOS上的python 2.7上安装rpy2

时间:2018-04-13 17:08:22

标签: macos python-2.7 clang openmp rpy2

我在macOS High Sierra上有python版本2.7.10并想安装rpy2。

当我做 sudo pip install rpy2

我收到错误消息:

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-Nwbha3/rpy2/

我已经升级了setuptools(版本39.0.1)。

我还下载了旧版rpy2-2.7.0.tar.gz并尝试使用 sudo pip install rpy2-2.7.0.tar.gz 进行安装。然后,我收到以下错误消息:

clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-O0cu4E-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-haDUA3-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-O0cu4E-build/

如果有人能解决我的安装问题,那将非常感激。 非常感谢提前!

1 个答案:

答案 0 :(得分:3)

Mac附带的clang不支持openmp,这是-fopenmp标志的用途。您可能需要一个支持openmp的clang版本。

一种可能的解决方案是使用openmp支持获得完整的llvm / clang构建。使用自制软件,您可以:

brew install llvm    # clang/llvm
brew install libomp  # OpenMP support

然后尝试使用新安装的clang版本再次安装rpy2

例如,当前版本为6.0.0,因此您可以运行

CC=/usr/local/Cellar/llvm/6.0.0/bin/clang pip install rpy2