Skip to content
Advertisement

Unable to determine R library path

I am new to R. I am running Jupyter Lab on a Windows 11 machine, and have created a virtual environment where I installed some packages and irkernel. I get the following message when I execute %load_ext rpy2.ipython:

JavaScript

Here is my complete code:

JavaScript

Apart from the environment variables, the above code comes from David Mertz book “Cleaning Data for Effective Data Science”. I need your help.

Advertisement

Answer

Note: This is a speculative answer as I don’t use Jupyter

That os.environ trick works for me in plain Python but Jupyter’s magic routine %load_ext rpy2.ipython utilizes LD_LIBRARY_PATH to set itself up. The error comes from the fact that LD_LIBRARY_PATH is Linux/Unix thing hence the trouble.

Failed Attempt #1 What you may be able to do is to add the following line to your os.environ calls:

JavaScript

Assuming ‘C:Usersephraminiconda3envscdeLibRbin’ exists. If not, look for a R subfolder with bunch of exe and dll files.

Attempt #2

Surveying further, I noticed that LD_LIBRARY_PATH itself is never used by rpy2, and it appears to be a Linux workaround. So, what happens if you comment out Lines 26-28 of Libsite-packagesrpy2rinterface_libopenrlib.py?

The lines should read

JavaScript

If this hack succeeds, let me know and I can file a PR.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement