You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I developed an R Package (lets call it 'myPackage') under Windows 10 / R 4.2.2
On my machine I could build a source package, install it, import it in Python and use it. Everything works well.
My colleague has to use it as well, but she uses a Mac and R 4.1.1. She could also build a source package on her machine and install it.
But when she tries to import it in Python an error gets thrown.
This is what we are trying:
from rpy2.robjects.packages import importr
from rpy2.robjects import r
# Set encoding to avoid errors with rpy2
r('Sys.setlocale("LC_ALL", "en_US.UTF-8")')
# import custom R package
importr('myPackage', lib_loc="/Library/Frameworks/R.framework/Versions/4.1/Resources/library")
We made sure, that the package actually was installed in the library location we specified. And as I said, when she ran library(myPackage) in RStudio, there was no error.
The error message we encountered is:
rpy2.rinterface_lib.embedded.RRuntimeError: Error in loadNamespace(name) : there is no package called 'myPackage'
Any idea whats the problem and how to solve it?
The text was updated successfully, but these errors were encountered:
It will tell you where it is installed. That path is not known to the embedded R in rpy2.
Thank you very much, but how can I tell the embedded R in rpy2 where to look for it?
I thought I already did this with: importr('myPackage', lib_loc="/Library/Frameworks/R.framework/Versions/4.1/Resources/library")
As I said we made sure, that the package actually was installed in the library location we specified
------EDIT-----
We ran installed.packages()["myPackage", ] and it told us the path we already knew: /Library/Frameworks/R.framework/Versions/4.1/Resources/library
Now my question: How to tell the embedded R in rpy2 this path?
There is always the possibility of rpy2's importr() not forwarding the argument about library location to the R function.
It does not seem to be the case though. At first sight R should get the information about the library location (although using a Python string as code to evaluate and trying to get the escaping of quotes is probable missing edge cases): https://github.com/rpy2/rpy2/blob/master/rpy2/robjects/packages.py#L80
Can you try importr() with suppress_messages=False?
I developed an R Package (lets call it 'myPackage') under Windows 10 / R 4.2.2
On my machine I could build a source package, install it, import it in Python and use it. Everything works well.
My colleague has to use it as well, but she uses a Mac and R 4.1.1. She could also build a source package on her machine and install it.
But when she tries to import it in Python an error gets thrown.
This is what we are trying:
We made sure, that the package actually was installed in the library location we specified. And as I said, when she ran
library(myPackage)
in RStudio, there was no error.The error message we encountered is:
rpy2.rinterface_lib.embedded.RRuntimeError: Error in loadNamespace(name) : there is no package called 'myPackage'
Any idea whats the problem and how to solve it?
The text was updated successfully, but these errors were encountered: