简体   繁体   中英

Importing mgcv fails because Rlapack.dll cannot be found

I want to link to the R statistical package in IronPython by using the R.NET library. It's been working fine, but now I need to use R's mgcv library.

Importing mgcv fails (import is done with the command rdn.r.EagerEvaluate("library(mgcv)") , where rdn is an IronPython object that wraps the R.NET library). When the import fails, Windows opens a dialog box that says: "The program can't start because Rlapack.dll is missing from your computer. Try reinstalling the program to fix this problem."

Of course, R never would have worked in the first place if Rlapack.dll was missing, so what is going on?

I inspected the dependencies of the mgcv package; they include the base package Matrix . As it turns out, Matrix has been compiled to a dll (found at ${R_HOME}/library/Matrix/libs/i386/Matrix.dll) by the R development team. That dll needs to link to Rlapack.dll, which for some reason it cannot find when R is called from R.NET in IronPython.

The solution was to drop a copy of Rlapack.dll (which you can find in ${R_HOME}/bin/i386/) into the same directory as Matrix.dll. Now every day is Sunday.

I had the same problem with compositions.dll .

So instead of copying the Rlapack.dll to the directory where compositions.dll exists, I added the bin directory to the PATH .

string rhome = System.Environment.GetEnvironmentVariable("R_HOME");
if (string.IsNullOrEmpty(rhome))
    rhome = @"C:\Program Files\R\R-2.14.0";

System.Environment.SetEnvironmentVariable("R_HOME", rhome);
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome + @"\bin\i386");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM