I\'m using Rpy2 on windows 7 64 and having trouble loading a package:
using(mi)
from rpy2.robjects
I had a similar problem:
rpy2.rinterface.RRuntimeError: Error in loadNamespace(name) : there is no package called speedglm
I noticed that the issue is that rpy2 does not know the location of all R libraries. In my case, typing (in R)
.libPaths()
gave me
[1] "/home/nbarjest/R/x86_64-redhat-linux-gnu-library/3.4"
[2] "/usr/lib64/R/library"
[3] "/usr/share/R/library"
While, typing (in Python 3)
import rpy2.rinterface
rpy2.rinterface.set_initoptions((b'rpy2', b'--no-save', b'--no-restore', b'--quiet'))
from rpy2.robjects.packages import importr
base = importr('base')
print(base._libPaths())
gave me only
[1] "/home/nbarjest/R/x86_64-redhat-linux-gnu-library/3.4"
I couldn't find a way to append the other two paths to base._libpath(). If you find a way to do it, please let me know. I used another workaround:
import rpy2
import rpy2.robjects as RObjects
from rpy2.robjects.packages import importr
utils = importr("utils")
d = {'print.me': 'print_dot_me', 'print_me': 'print_uscore_me'}
try:
thatpackage = importr('speedglm', robject_translations = d, lib_loc = "/home/nbarjest/R/x86_64-redhat-linux-gnu-library/3.4")
except:
try:
thatpackage = importr('speedglm', robject_translations = d, lib_loc = "/usr/lib64/R/library")
except:
thatpackage = importr('speedglm', robject_translations = d, lib_loc = "/usr/share/R/library")
This works. I hope other people who have the same problem find this useful.