在 Mac 上安装 rpy2 时出错

error installing rpy2 on Mac

我正在尝试在 python 2.7.14 和 Mac OS High Sierra 版本 10.13.2 上安装 rpy2,但是当我尝试编写命令时

pip install rpy2

我得到以下输出:

Collecting rpy2
  Using cached rpy2-2.9.2.tar.gz
    Complete output from command python setup.py egg_info:
    rpy2 is no longer supporting Python < 3. Consider using an older rpy2 release when using an older Python release.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/11/xgl2d8l16wd8xv2_lmdtcmwc0000gn/T/pip-build-aJMHfU/rpy2/
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我已经尝试通过键入

来升级 pip 包
pip install --upgrade pip

但我收到以下消息:

Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我能够在 python3 上安装 rpy2,但由于某些原因它没有安装在 python2 上。

这是我的 python2 的规格:

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

任何帮助将不胜感激!

声明只有python支持最新版本 3.

rpy2 is no longer supporting Python < 3. Consider using an older rpy2 release when using an older Python release.

如果确实需要使用python2,尝试下载旧版本的rpy2和build it from source

版本 2.8.6 是 rpy2 的最后一个版本,它支持 Python 的 2.x 系列。

你可以告诉pip具体安装那个版本:

pip install rpy2==2.8.6

为什么一个包管理器——它的全部目的就是处理依赖管理——不能靠自己成功解决这个问题,我不知道。