LookupError: 'show' not found

Issue #152 resolved
Anonymous created an issue

There was already an issue for this bug, but I've run into it again. I'm on my 3-4th install of R/rpy2 today and this is the last hurdle I've gotten (rest were pretty common errors).

Here's the stack trace of the initial error (happened when starting the gunicorn server):

  File "/usr/share/nginx/forecast/forecast/jobs.py", line 7, in <module>
    import rpy2.robjects as robjects
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 18, in <module>
    from rpy2.robjects.robject import RObjectMixin, RObject
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 9, in <module>
    class RObjectMixin(object):
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 22, in RObjectMixin
    __show = rpy2.rinterface.baseenv.get("show")
LookupError: 'show' not found

Running tests.py:

rpy2 version: 2.3.8
built against R version: 2-15.3--140076110783609
Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function
Traceback (most recent call last):
  File "tests.py", line 9, in <module>
    import rpy2.robjects.tests
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 18, in <module>
    from rpy2.robjects.robject import RObjectMixin, RObject
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 9, in <module>
    class RObjectMixin(object):
  File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 22, in RObjectMixin
    __show = rpy2.rinterface.baseenv.get("show")
LookupError: 'show' not found

R version on the machine (same as the compiled version for rpy2):

R version 2.15.3 (2013-03-01) -- "Security Blanket"

If I can provide any more useful information, let me know.

Comments (16)

  1. Laurent Gautier

    Usually this caused because of incompatible compiled C libraries between the R used at build time and the R picked up at run time.

    Here the, the second line when running python -m rpy2.tests reports a rather unusual R version:

    built against R version: 2-15.3--140076110783609
    

    If want/dare trying rpy2-2.4.0-dev, the reporting of which R version is used when running the tests is a little better:

    pip install https://bitbucket.org/lgautier/rpy2/get/version_2.4.x.tar.gz
    
  2. Andrew Ryno

    Here's what that got me:

    Error in paste0("(^|[^%])(%%)*%", spec) : not a BUILTIN function
    rpy2 version: 2.4.0
    - built against R version: 2-15.3--140105607259449
    - running linked to R version: R version 2.14.1 (2011-12-22)
    Traceback (most recent call last):
      File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/usr/share/nginx/forecast/venv/lib/python2.7/site-packages/rpy2/tests.py", line 81, in <module>
        main(verbosity=1)
      File "/usr/share/nginx/forecast/venv/lib/python2.7/site-packages/rpy2/tests.py", line 51, in main
        'test*')
      File "/usr/share/nginx/forecast/venv/lib/python2.7/site-packages/rpy2/tests.py", line 23, in faster_load_tests
        suite_robjects = loader.discover('robjects', pattern, rpy_root)
      File "/usr/lib/python2.7/unittest/loader.py", line 190, in discover
        __import__(start_dir)
      File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 18, in <module>
        from rpy2.robjects.robject import RObjectMixin, RObject
      File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 18, in <module>
        from rpy2.robjects.robject import RObjectMixin, RObject
      File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 9, in <module>
        class RObjectMixin(object):
      File "/usr/share/nginx/forecast/venv/local/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 22, in RObjectMixin
        __show = rpy2.rinterface.baseenv.get("show")
    LookupError: 'show' not found
    

    Same error, and it's showing it's using 2.4.0. :\ I've already reinstalled R a few times (using http://cran.r-project.org/src/base/R-2/R-2.15.3.tar.gz).

    Edit: just noticed the "running linked to R version" bit, which reports a different R version. That must be the problem?

  3. Andrew Ryno

    Well, turns out I didn't have the repository set after I rebuilt the server. So it installed r-base-dev (and other dependency packages) 2.14, instead of the 2.15.3 I compiled from source. Stupid problem.

    Edit: Since I accidentally made this issue anonymous, could you close? Thanks!

  4. Nicholas Youngblut

    I'm getting a very similar error, and I don't have r-base-dev installed. My setup:

    # Sever: Ubuntu 14.04 x86_64. 
    # Anaconda (for python3.5) install
    wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
    bash Anaconda3-4.2.0-Linux-x86_64.sh -b -p `pwd`"/anaconda3"
    conda update conda
    
    # Creating conda environment
    conda create -y -n test_py2 python=2
    conda install -c r rpy2
    

    When I load the rpy2.ipython extension in Jupyter, I get the following:

    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-3-691c6d73b073> in <module>()
    ----> 1 get_ipython().magic(u'load_ext rpy2.ipython')
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
       2156         magic_name, _, magic_arg_s = arg_s.partition(' ')
       2157         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
    -> 2158         return self.run_line_magic(magic_name, magic_arg_s)
       2159 
       2160     #-------------------------------------------------------------------------
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
       2077                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
       2078             with self.builtin_trap:
    -> 2079                 result = fn(*args,**kwargs)
       2080             return result
       2081 
    
    <decorator-gen-62> in load_ext(self, module_str)
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
        186     # but it's overkill for just that one bit of state.
        187     def magic_deco(arg):
    --> 188         call = lambda f, *a, **k: f(*a, **k)
        189 
        190         if callable(arg):
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str)
         35         if not module_str:
         36             raise UsageError('Missing module name.')
    ---> 37         res = self.shell.extension_manager.load_extension(module_str)
         38 
         39         if res == 'already loaded':
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/IPython/core/extensions.pyc in load_extension(self, module_str)
         81             if module_str not in sys.modules:
         82                 with prepended_to_syspath(self.ipython_extension_dir):
    ---> 83                     __import__(module_str)
         84             mod = sys.modules[module_str]
         85             if self._call_load_ipython_extension(mod):
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/rpy2/ipython/__init__.py in <module>()
    ----> 1 from .rmagic import load_ipython_extension
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/rpy2/ipython/rmagic.py in <module>()
         51 
         52 import rpy2.rinterface as ri
    ---> 53 import rpy2.robjects as ro
         54 import rpy2.robjects.packages as rpacks
         55 Converter = ro.conversion.Converter
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/rpy2/robjects/__init__.py in <module>()
         16 import rpy2.rlike.container as rlc
         17 
    ---> 18 from rpy2.robjects.robject import RObjectMixin, RObject
         19 from rpy2.robjects.vectors import (BoolVector,
         20                                    IntVector,
    
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_ley0.4/lib/python2.7/site-packages/rpy2/robjects/robject.py in <module>()
          6 rpy2.rinterface.initr()
          7 
    ----> 8 from . import conversion
          9 
         10 class RSlots(object):
    
    ImportError: cannot import name conversion
    

    The R packages in my conda environment are:

    r                         3.3.2                  r3.3.2_0    r
    r-base                    3.3.2                         1    r
    r-boot                    1.3_18                 r3.3.2_0    r
    r-class                   7.3_14                 r3.3.2_0    r
    r-cluster                 2.0.5                  r3.3.2_0    r
    r-codetools               0.2_15                 r3.3.2_0    r
    r-foreign                 0.8_67                 r3.3.2_0    r
    r-kernsmooth              2.23_15                r3.3.2_0    r
    r-lattice                 0.20_34                r3.3.2_0    r
    r-mass                    7.3_45                 r3.3.2_0    r
    r-matrix                  1.2_7.1                r3.3.2_0    r
    r-mgcv                    1.8_16                 r3.3.2_0    r
    r-nlme                    3.1_128                r3.3.2_0    r
    r-nnet                    7.3_12                 r3.3.2_0    r
    r-recommended             3.3.2                  r3.3.2_0    r
    r-rpart                   4.1_10                 r3.3.2_0    r
    r-spatial                 7.3_11                 r3.3.2_0    r
    r-survival                2.40_1                 r3.3.2_0    r
    readline                  6.2                           0    conda-forge
    rpy2                      2.8.5              py27r3.3.2_2    r
    python                    2.7.12                        1    conda-forge
    

    Any ideas on what's going wrong? It seems that no matter how I try to install rpy2 in a python 2.7 conda environment, rpy2 throws errors when I try to load it in a Jupyter notebook (with the same conda environment). However, I can get rpy2 to work with a python 3.5 conda environment. Should I just stick to python 3.5? Thanks

  5. jshanna

    I'm running Python 3.5.2 in a conda environment with rpy2 2.8.5 and R_VERSION_BUILD '3', '3.2', '', 71607. Rpy2 works perfectly fine in a python interpreter, but the same commands fail in an ipython console within Spyder, e.g.:

    import rpy2.robjects as robjects
    
    Traceback (most recent call last):
    
      File "<ipython-input-10-645b0f765c67>", line 1, in <module>
        import rpy2.robjects as robjects
    
      File "/home/jeff/anaconda3/lib/python3.5/site-packages/rpy2/robjects/__init__.py", line 19, in <module>
        from rpy2.robjects.robject import RObjectMixin, RObject
    
      File "/home/jeff/anaconda3/lib/python3.5/site-packages/rpy2/robjects/robject.py", line 58, in <module>
        class RObjectMixin(object):
    
      File "/home/jeff/anaconda3/lib/python3.5/site-packages/rpy2/robjects/robject.py", line 71, in RObjectMixin
        __show = rpy2.rinterface.baseenv.get("show")
    
    LookupError: 'show' not found
    

    My Spyder console points to the same (conda) python interpreter, and when I run version checks in both the interpreter and the Spyder IPython console, they are both using the same rpy2 and R installations. What could be causing this?

  6. Laurent Gautier

    @jshanna My recollection of online discussions about this is that Spyder is defining an execution environment that may differ from a shell (e.g., redefines the environment variable PATH and/or LD_LIBRARY_PATH), but I am not certain about this and this should be checked with Spyder support / on mailing lists.

    There is a module in the repos that is trying to help with diagnosing problems. It will be included with rpy2-2.9.0, but the code should run if copy/paste it into your ipython console (https://bitbucket.org/rpy2/rpy2/src/b5b64fa3a5e93e9f00e37ebccf3becbfe05871b5/rpy/situation.py?at=default&fileviewer=file-view-default)

  7. Nicholas Youngblut

    I ran python -m rpy2.tests in my Python 2.7.12 environment, and I got the following:

    rpy2 version: 2.8.5
    - built against R version: 3-3.2--71607
    - running linked to R version: R version 3.3.2 (2016-10-31)
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_test/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: Error in loadNamespace(name) : there is no package called ‘ggplot2’
    
      warnings.warn(x, RRuntimeWarning)
    .............................................................................................................................................................s.s.............s..........sssssssssssssssssssssssssss...............................................................................................x..............................................ssssssssss................................s.....
    ----------------------------------------------------------------------
    Ran 401 tests in 9.700s
    
    OK (skipped=41, expected failures=1)
    

    I then installed ggplot2 with conda install -c r r-ggplot2 (r-ggplot2: 2.2.0-r3.3.2_0), and I re-ran the rpy2 tests:

    rpy2 version: 2.8.5
    - built against R version: 3-3.2--71607
    - running linked to R version: R version 3.3.2 (2016-10-31)
    .............................................................................................................................................................s.s.............s..........sssssssssssssssssssssssssss...............................................................................................x..............................................sssssss...................................s.....
    ----------------------------------------------------------------------
    Ran 401 tests in 7.103s
    
    OK (skipped=38, expected failures=1)
    
  8. Nicholas Youngblut

    I thought that running the rpy2 tests in a bash shell in Jupyter would be the same as running them on the command line in the same conda environment. However, I tried running the tests in a Jupyter notebook (here's the notebook cell):

    %%bash
    # activate the conda environment
    source activate py2_test
    # run the rpy2 tests
    python -m rpy2.tests
    

    ...and here's the output

    rpy2 version: 2.8.5
    - built against R version: 3-3.2--71607
    - running linked to R version: R version 3.0.2 (2013-09-25)
    /ebio/abt3_projects/methanogen_host_evo/anaconda3/envs/py2_test/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: Error in objects(db.pos, all.names = TRUE) : 
      2 arguments passed to .Internal(ls) which requires 3
    
      warnings.warn(x, RRuntimeWarning)
    E
    ======================================================================
    ERROR: __main__ (unittest.loader.LoadTestsFailure)
    ----------------------------------------------------------------------
    LookupError: 'show' not found
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
    
    FAILED (errors=1)
    

    So, it appears the rpy2 isn't working with my Jupyter Notebook install.

  9. Laurent Gautier

    I thought that running the rpy2 tests in a bash shell in Jupyter would be the same as running them on the command line in the same conda environment.

    I would have the same as well.

    %%bash
    # activate the conda environment
    source activate py2_test
    # run the rpy2 tests
    python -m rpy2.tests
    

    Hold a second. Is the virtualenv py2_test the one that also contains your jupyter server ? If so, there is no need to source it again.

  10. Nicholas Youngblut

    I don't know why, but for py2_test, I can't create a Jupyter kernel that will run with that conda environment, even though it contains my Jupyter server. When I activate the py2_test conda environment (py2_test) and then start up the Jupyter server, I the py2_test conda environment is listed under the 'conda' tab:

    Screen Shot 2017-02-01 at 10.39.03.png

    however, I can't start up a kernel with the py2_test environment:

    Screen Shot 2017-02-01 at 10.39.10.png

    and the default conda kernel runs with the conda root environment:

    Screen Shot 2017-02-01 at 10.43.26.png

    Regardless, rpy2 isn't working in any python v2.7 environment that I create with conda. Should I try running the tests in some other way?

  11. Greg Silverman

    I'm having a similar issue, although I am running from ipython (version 5.3.0). I just upgraded to R 3.4.0 after upgrading to MacOS 10.12.4.

    The tests gave me no errors (see below).

    Output of tests:

    (evaluate_it) greg-silvermans-macbook-pro-2:evaluate_it gregsilverman$ python -m rpy2.tests
    rpy2 version: 2.8.5
    - built against R version: 3-3.2--71607
    - running linked to R version: R version 3.3.2 (2016-10-31)
    .............................................................................................................................................................s.s.............s.....sssssss..................................................x.................................................................................................................................................................s......s.....
    ----------------------------------------------------------------------
    Ran 411 tests in 6.122s
    
    OK (skipped=12, expected failures=1)
    

    The error I get is:

    In[2]: from rpy2.robjects import pandas2ri
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning:  警告メッセージ: 
    
      warnings.warn(x, RRuntimeWarning)
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning:  local({ : 
      warnings.warn(x, RRuntimeWarning)
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning:   バイトコードのバージョンが不一致です; eval を使います 
    
      warnings.warn(x, RRuntimeWarning)
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning:  起動準備中です - 
      warnings.warn(x, RRuntimeWarning)
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning:  13 件の警告がありました (警告を見るには warnings() を使って下さい) 
      warnings.warn(x, RRuntimeWarning)
    /Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186: RRuntimeWarning: 
    
      warnings.warn(x, RRuntimeWarning)
    Traceback (most recent call last):
      File "/Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
        exec(code_obj, self.user_global_ns, self.user_ns)
      File "<ipython-input-2-cc52694d111a>", line 1, in <module>
        from rpy2.robjects import pandas2ri
      File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "/Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 19, in <module>
        from rpy2.robjects.robject import RObjectMixin, RObject
      File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
        module = self._system_import(name, *args, **kwargs)
      File "/Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 58, in <module>
        class RObjectMixin(object):
      File "/Users/gregsilverman/anaconda/envs/evaluate_it/lib/python2.7/site-packages/rpy2/robjects/robject.py", line 71, in RObjectMixin
        __show = rpy2.rinterface.baseenv.get("show")
    LookupError: 'show' not found
    

    Now, here is the strange thing; this works fine from the command line version of conda python version 2.7.13 (so, it would seem to be an iPython issue):

    (evaluate_it) greg-silvermans-macbook-pro-2:evaluate_it gregsilverman$ python
    Python 2.7.13 |Anaconda custom (x86_64)| (default, Dec 20 2016, 23:05:08) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    Anaconda is brought to you by Continuum Analytics.
    Please check out: http://continuum.io/thanks and https://anaconda.org
    >>> from rpy2.robjects import pandas2ri
    >>> 
    

    Any suggestions, beyond using conda? I have several scripted magic commands that require I use ipython.

  12. Greg Silverman

    I just tried this in Jupyter notebook and it was fine. Also, I tried it in a conda virtual environment using ipython from the command line, and it was fine. I am just having trouble in ipython running from a Python console in Pycharm (same exact version of ipython, btw, both sharing the same virtual environment!). Please advise.

  13. Log in to comment