eandy
eandy

Reputation: 21

Anaconda import error for rpy2

I have a problem with using rpy2 on Anaconda Python. The issue is that it fails to import due to the following TypeError:

TypeError: type 'rpy2.rinterface.StrSexpVector' is not an acceptable base type

My python version is 3.5, my anaconda version is 4.0.0, my rpy2 version is 2.7.0.

The problem seems to be that Anaconda now uses version 3.5 which is not compatible with rpy2 2.7.3 or lower, see https://bitbucket.org/rpy2/rpy2/issues/313/typeerror-type-rpy2rinterfacestrsexpvector - as Anaconda currently default installs 2.7.0 the import fails. How can this issue be fixed?

The issue is similar to the one asked here, Error when loading rpy2 with anaconda, however, the old solution of installing 2.7.0 is no longer compatible as explained above.

Upvotes: 2

Views: 1022

Answers (1)

IanSR
IanSR

Reputation: 10556

If you happen to be on OS X, I've built Conda packages for rpy2 2.8.0 which you can get with:

conda install -c ijstokes rpy2=2.8.0

These are available for Python 2.7 and 3.5. The problem stems from this rpy2 bug which has now been fixed: https://bitbucket.org/rpy2/rpy2/issues/313/typeerror-type-rpy2rinterfacestrsexpvector

If you're not on OS X, then you can build your own version with something like:

conda skeleton pypi rpy2 --version=2.8.0 --python=3.5
conda build rpy2
conda install --use-local rpy2

Those commands are from memory, but they should work or be close enough you can figure out the exact options.

Upvotes: 0

Related Questions