提问人:buguette 提问时间:11/7/2023 更新时间:11/7/2023 访问量:56
设置 rpy2
Setting up rpy2
问:
我尝试在安装了 R 版本 2.5.14 的 python 版本 3.10.11 上运行 rpy4.3.2 版本 我已经查找了一些针对“无法加载库”错误0x7e修复程序,但不知何故,这些修复程序无法做到这一点。
我在 VScode 中的代码应该可以解决问题,如下所示:
try:
import rpy2.robjects as robjects
except OSError as e:
try:
import os
import platform
if ('Windows') in platform.system():
os.environ["R_HOME"] = 'C:/Program Files/R/R-4.3.2/bin/x64' # Your R version here
os.environ["PATH"] = "C:/Program Files/R/R-4.3.2/bin/x64" + ";" + os.environ["PATH"]
#os.environ["PATH"] = 'C:\\Program Files\\R\\R-4.3.2\\bin\\x64\\R.dll' + ";" + os.environ["PATH"]
import rpy2.robjects as robjects
except OSError:
raise(e)
错误消息如下:
Traceback (most recent call last):
File "E:\Python\Codes\GSADF\rpy2_test.py", line 13, in <module>
raise(e)
File "E:\Python\Codes\GSADF\rpy2_test.py", line 2, in <module>
import rpy2.robjects as robjects
File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\rpy2\robjects\__init__.py", line 16, in <module>
import rpy2.rinterface as rinterface
File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\rpy2\rinterface.py", line 19, in <module>
from rpy2.rinterface_lib import openrlib
File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\rpy2\rinterface_lib\openrlib.py", line 58, in <module>
rlib = _dlopen_rlib(R_HOME)
File "C:\Users\thoma\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\rpy2\rinterface_lib\openrlib.py", line 51, in _dlopen_rlib
rlib = ffi.dlopen(lib_path)
OSError: cannot load library 'C:\Program Files\R\R-4.3.2\bin\x64\R.dll': error 0x7e
我现在坐了好几天了,不知何故没有什么能解决这个问题
提前致谢
答: 暂无答案
评论