5

python 3.7.3, rpy2 3.2.0, the following code:

from rpy2 import robjects

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".virtualenvs/flask3/lib/python3.7/site-packages/rpy2/robjects/__init__.py", line 14, in <module>
    import rpy2.rinterface as rinterface
  File ".virtualenvs/flask3/lib/python3.7/site-packages/rpy2/rinterface.py", line 6, in <module>
    from rpy2.rinterface_lib import openrlib
  File ".virtualenvs/flask3/lib/python3.7/site-packages/rpy2/rinterface_lib/openrlib.py", line 65, in <module>
    _get_dataptr_fallback)
  File ".virtualenvs/flask3/lib/python3.7/site-packages/rpy2/rinterface_lib/openrlib.py", line 50, in _get_symbol_or_fallback
    res = getattr(rlib, symbol)
RuntimeError: found a situation in which we try to build a type recursively.  This is known to occur e.g. in ``struct s { void(*callable)(struct s); }''.  Please report if you get this error and really need support for your case.

What's going on? This looks like standard procedure for rypy2, and indeed how we used it under python 2.

Same issue applies for any kind of rpy2 import: import rpy2.robjects.tests etc.

Wells
  • 10,415
  • 14
  • 55
  • 85
  • 2
    I'm also having this issue when trying to use rpy2 for testing on Travis. Looks like it's an issue with the cffi dependency of rpy2 which just got updated on conda: https://bitbucket.org/rpy2/rpy2/issues/591/runtimeerror-found-a-situation-in-which-we – ejolly Oct 16 '19 at 05:19

2 Answers2

3

I ran into the same problem and found the same issue @ejolly linked above. To get around it, I downgraded my cffi library from 1.13.0 to 1.12.3.

pip install cffi==1.12.3

Worked like a charm.

ramhiser
  • 3,342
  • 3
  • 23
  • 29
  • It sure does-- frustrating, but that seems to be the ticket (at least with me in python 3.7.3) – Wells Oct 17 '19 at 16:57
2

edit:cffi 1.13.1 is released. Just update it and all should work.


The issue appeared with cffi 1.13.0, but appears limited to the ABI mode.

rpy2 will try to use the API mode, but if it fails will silently fall back to the ABI mode. If your system can be configured to have a C compiler, the API mode should be installed. To force the use of the API mode, set the environment variable:

RPY2_CFFI_MODE=API

(see info box in the doc: https://rpy2.github.io/doc/v3.2.x/html/overview.html#install-from-source)

lgautier
  • 11,363
  • 29
  • 42