在 MacOS 上安装 rpy2

Installing rpy2 on MacOS

我一直在尝试在 MacOS Sierra 上为 Python 3.6 安装 RPy2,但是 pip 安装在没有编译的情况下失败了。

安装错误并显示消息:

  clang: error: unsupported option '-fopenmp'
  error: command 'clang' failed with exit status 1

任何有关安装的帮助将不胜感激。

this 线程中找到了解决方案。

env CC=/usr/local/Cellar/gcc/X.x.x/bin/gcc-X pip install rpy2

运行 通过将 gcc 版本替换为 machine 上的最新版本,上述命令应该可以解决问题。例如,在我的 mac 上,我 运行

env CC=/usr/local/Cellar/gcc/8.2.0/bin/gcc-8 pip install rpy2

如果您安装了 python 包 wheel,我相信 pip install 应该获取 OS X 的预编译二进制文件。

如果使用 Miniconda 环境,这有效:

conda install -c r rpy2

发件人:https://anaconda.org/r/rpy2

  • macOS 莫哈韦

  • Python 3.8