After upgrading R and rpy2 I found a LoadLibrary failure problem with rpy2 when importing the R package stats. After running the following code:
import rpy2.robjects as robjects
from rpy2.objects.packages import importr
rstats = importr('stats')
I receive the error message
RRuntimeError: Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object 'C:/Program Files/R/R-3.4.3/library/stats/libs/x64/stats.dll':
LoadLibrary failure: The specified module cannot be found.
Other modules are imported correctly, unless they import stats themselves. I have tried to reinstall R and rpy2 to no avail. A similar issue reported a problem with a path in the .Renviron file. This file does not exist in my computer.
My R_HOME is C:\\Program Files\\R\\R-3.4.3 and my R_USER is C:\\Users\\user.name.
Could you help me find what is the problem and how to solve it?
I solved the problem by adding C:\\Program Files\\R\\R-3.4.3\\bin\\x64 to the path. I think that this address was deleted from the path when I uninstalled the previous R version. And you need to install the address manually to the path after installing the new version, according to the R for Windows FAQ .
For those with anaconda, I solved the problem using conda install rpy2
Also added the entry C:\\Program Files\\R\\R-4.0.2\\bin\\x64
to my user Path
variable.
And added the variable R_HOME
with value C:\\Program Files\\R\\R-4.0.2
And added the variable R_USER
with value C:\\ProgramData\\Anaconda3\\Lib\\site-packages\\rpy2
I tried many different suggestions, but this was the only solution.
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.