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?

2
  • I used the solution from a similar question: uninstall and reinstall anaconda. stackoverflow.com/questions/33672565/…
    – Chris
    Nov 22, 2017 at 21:44
  • 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.
    – anilbey
    Feb 1, 2018 at 15:12

1 Answer 1

13

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

3
  • Thanks, it worked for me. It's the only solution I could find online. Nov 21, 2017 at 12:18
  • 1
    as of august 2018, installing r-essentials does not install libiconv automatically. Aug 21, 2018 at 11:20
  • As of Apr 2020, installing libiconv using conda still works. Apr 21, 2020 at 15:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.