rpy2 doesn't work - requires libiconv.so.2
Asked Answered
C

1

9

I have a relatively fresh installation of anaconda, in which I installed rpy2 using "conda install rpy2". However, when I try running it, I get this error, e.g.:

> /[dir]/anaconda/bin/python -m 'rpy2.tests'
Traceback (most recent call last):
  File "/[dir]/anaconda/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/[dir]/anaconda/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "[dir]/anaconda/lib/python2.7/site-packages/rpy2/tests.py", line 23, in <module>
    import rpy2.tests_rpy_classic
  File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/tests_rpy_classic.py", line 3, in <module>
    import rpy2.rpy_classic as rpy
  File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/rpy_classic.py", line 5, in <module>
    import rpy2.rinterface as ri
  File "/[dir]/anaconda/lib/python2.7/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
    from rpy2.rinterface._rinterface import (baseenv,
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory

What is this libiconv.so.2, and why doesn't it work straight from the box?

Crocodile answered 14/2, 2017 at 9:17 Comment(2)
I used the solution from a similar question: uninstall and reinstall anaconda. #33673065Chemism
Sometimes installing it through pip also solves the problem. Note: pip installed packages are also detected by conda (you can see them by running the conda list command.Solenoid
C
13

I think you need to conda install -c r libiconv or perhaps install r-essentials, which contains libiconv.

Cuzco answered 29/5, 2017 at 20:59 Comment(3)
Thanks, it worked for me. It's the only solution I could find online.Winograd
as of august 2018, installing r-essentials does not install libiconv automatically.Freeway
As of Apr 2020, installing libiconv using conda still works.Tahr

© 2022 - 2024 — McMap. All rights reserved.