Gabriel Gabriel - 1 year ago 126
Python Question

Install rpy2 inside virtualenv (can't find library)

I have a Python virtualenv set up with pyenv-virtualenv. I installed the R statistical software, and now I need to install the rpy2 package to allow communication between Python and R.

Both Python v2.7.12 and R version 3.3.1 (2016-06-21) are installed.

Attempting to install

pip install rpy2
fails with:

/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/';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

is already installed in my system.

How can I bypass this issue?

Answer Source

I would finally install the package successfully.

The issue was that I had installed the python-dev library after the virtualenv was created. This caused the installation of the rpy2 package to fail.

The solution was to uninstall the virtualenv and create again from scratch.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download