Importing mgcv fails because Rlapack.dll cannot be found

筅森魡賤 提交于 2019-12-07 09:55:15

问题


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?


回答1:


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.




回答2:


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");


来源:https://stackoverflow.com/questions/7960738/importing-mgcv-fails-because-rlapack-dll-cannot-be-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!