I have installed rpy2 Version 2.9.4 successfully using Anaconda. I am using Python 3.7.4 (64bit) and the python environment Anaconda 5.2 in Visual Studio 2017
I have set R_HOME path variable to C:\Program Files\R\R-3.6.1 and Path variable to C:\Program Files\R\R-3.6.1\bin\x64
In Python I have imported rpy2:
import rpy2
But I can not use rpy2. When I run
import rpy2
from rpy2.robjects import r
then the R.dll of my R Installation can not be found
(Unable to locate R.dll at C:\Program Files\R\R-3.6.1\bin\bin\x64\R.dll)
I tried to change the environment variables and it did not work. I found similiar problems at stackoverflow here and they were less helpful for me.
Also the path showing in the error message is wrong according to the real path to R.dll.
When I tried it few times there sometimes the path had other wrong structures like ...R-3.6.1\bin\x64\bin\x64\R.dll or the structure in the error message above.
I also found out that Python is installed in C:\Users\\AppData\Local\Programs\Python\Python37 instead of C:\Program Files.
I examined that path and found out that rpy2 is not in …\Python\Python37\Lib\site-packages.
I saw a similiar path in the post here. It is saved in R_USER there.
Here I found the source code where the R.dll is tried to load and the error is thrown. I also saw that there are hard coded strings 'bin' and 'lib'. The R version is 2.12. there. In my Installation directory of R there is no folder lib but there is a Folder libraries (in: C:\Program Files\R\R-3.6.1).
Is there still a bug in the source code of rpy2 2.9.4 (hard coded Folder name) causing that R.dll can not be found?
Other versions of rpy2 can not be installed because it leads to another special error like I posted here.
Does anyone have an idea how R.dll can be found without any problems?