在 virtualenv 中安装 rpy2(找不到库)

Install rpy2 inside virtualenv (can't find library)

我有一个 Python virtualenv 设置 pyenv-virtualenv. I installed the R statistical software, and now I need to install the rpy2 包允许 Python 和 R.

之间的通信

已安装Python v2.7.12 和 R 版本 3.3.1 (2016-06-21)。

尝试使用 pip install rpy2 安装 rpy2 失败:

    /usr/bin/ld: no se puede encontrar -llzma
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/home/gabriel/.pyenv/versions/2.7.12/envs/test-env/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-b7O2v3/rpy2/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4SXyxe-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/gabriel/.pyenv/versions/2.7.12/envs/asteca-env/include/site/python2.7/rpy2" failed with error code 1 in /tmp/pip-build-b7O2v3/rpy2/

no se puede encontrar -llzma 表示 can't find -llzma.

python-dev 已经安装在我的系统中。

如何绕过这个问题?

我终于可以成功安装包了。

问题是我在 创建 virtualenv 之后 安装了 python-dev 库。这导致 rpy2 软件包安装失败。

解决方案是卸载 virtualenv 并从头开始重新创建。