Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpy2 3.2.0 on python 3.7 issues w/ importing robjects

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.

like image 377
Wells Avatar asked Oct 15 '19 18:10

Wells


2 Answers

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.

like image 96
ramhiser Avatar answered Nov 15 '22 08:11

ramhiser


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)

like image 25
lgautier Avatar answered Nov 15 '22 06:11

lgautier