Open hschult opened 1 year ago
Thanks for filing this!
I think we need specifics on exactly how it was registered as a kernel, where is Jupyter installed (user level?), and what environment is active when Jupyter is launched.
Essentially, r-base
package is responsible for setting R_HOME
when the environment is activated. But if Jupyter only recognizes this kernel as a Python kernel, then it probably won't run the environment's activation scripts to initialize these values.
Thank you for the explanation.
To answer your questions:
I registered the kernel by running the following command after activating the "rpy2" environment from above.
python -m ipykernel install --user --name rpy2 --display-name "rpy2"
I could find out that Jupyter is located in my base environment which is in /opt
. So it should be root level and base is probably active when Jupyter is launched. Though, I would have to ask my IT to get more details.
I hope that helps and thanks for looking into it.
@hschult, the same problem confused me, thanks for your answer!
import os
os.environ["R_HOME"] = "/workspace/.conda/rpy2/lib/R"
import rpy2.robjects``
it worked
Solution to issue cannot be found in the documentation.
Issue
Basically the problem reported here: https://github.com/rpy2/rpy2/issues/858
I created an environment with:
mamba create -n rpy2 rpy2 ipykernel anndata2ri
registered it as a kernel and tried to importrpy2.robjects
which gave me the following error:Interestingly if I open python in the terminal and do the same import it works just fine. Also since the error states that the path to r_home is missing I tried to set it.
When the above is done directly after restarting the kernel it works just fine. I guess there might be an additional path variable in jupyter that needs to be set during installation?
Installed packages
Environment info