Suppress importr exceptions behind mod_wsgi

Issue #277 closed
Serrano Pereira created an issue

Due to issue #274 this will fail with a LibraryError exception:

>>> import rpy2
>>> import rpy2.rinterface
>>> from rpy2.robjects.packages import importr
>>> print(rpy2.__version__)
>>> rpy2.rinterface.R_VERSION_BUILD
('3', '2.0', '', 68180L)
>>> stats = importr('stats')
Traceback (most recent call last):
rpy2.robjects.packages.LibraryError: Conflict when converting R symbol in the package "stats" to a Python symbol (format.perc -> format_perc while there is already format_perc)

The exception can be suppressed as follows:

stats = importr('stats', on_conflict="warn")

The issue I'm having is that on_conflict="warn" has no effect if it is used in a Django application served via Apache and mod_wsgi. It will still raise the same LibraryError exception. The exception is suppressed as expected if the application is served via Django's development server.

See also

Comments (2)

  1. Laurent Gautier

    This is looking extremely odd.

    It would mean that either rpy2 changes its behavior when Django + Apache are used (and it does not do the first, and has no way to know the second), or Django+Apache modify rpy2's code (I don't think that this is the case).

    A number of issues reported with Apache + rpy2 were because Apache was importing a different installation of rpy2 than expected.

  2. Log in to comment