gpt4 book ai didi

python - 操作系统错误 : cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll' : error 0x7e

转载 作者:行者123 更新时间:2023-12-03 19:41:29 29 4
gpt4 key购买 nike

我正在尝试将 rpy2 库导入 Jupyter Notebook,但我无法克服此错误。
添加了 PATH 'C:\Program Files\R\R-4.0.2\bin\x64'。
这是我计算机上安装的唯一 R 版本。我已经完全卸载并重新安装了 R/Rstudio/Anaconda,但没有运气。
这是完整的错误:

---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-7-098f0d39b3a3> in <module>
----> 1 from rpy2.robjects import pandas2ri

C:\Anaconda\lib\site-packages\rpy2\robjects\__init__.py in <module>
14 from functools import partial
15 import types
---> 16 import rpy2.rinterface as rinterface
17 import rpy2.rlike.container as rlc
18

C:\Anaconda\lib\site-packages\rpy2\rinterface.py in <module>
4 import typing
5 from typing import Union
----> 6 from rpy2.rinterface_lib import openrlib
7 import rpy2.rinterface_lib._rinterface_capi as _rinterface
8 import rpy2.rinterface_lib.embedded as embedded

C:\Anaconda\lib\site-packages\rpy2\rinterface_lib\openrlib.py in <module>
42 rlib = _rinterface_cffi.lib
43 else:
---> 44 rlib = _dlopen_rlib(R_HOME)
45
46

C:\Anaconda\lib\site-packages\rpy2\rinterface_lib\openrlib.py in _dlopen_rlib(r_home)
35 raise ValueError('The library path cannot be None.')
36 else:
---> 37 rlib = ffi.dlopen(lib_path)
38 return rlib
39

OSError: cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll': error 0x7e

编辑:
这是我运行以导入 rpy2 库的代码:
from rpy2.robjects import r, pandas2ri

最佳答案

这是我的工作解决方案:

import os
os.environ["R_HOME"] = r"D:\Install\R\R-3.6.1"
os.environ["PATH"] = r"D:\Install\R\R-3.6.1\bin\x64" + ";" + os.environ["PATH"]
import rpy2
from rpy2.robjects import pandas2ri, packages
pandas2ri.activate()
stats = packages.importr('stats')

关于python - 操作系统错误 : cannot load library 'C:\Program Files\R\R-4.0.2\bin\x64\R.dll' : error 0x7e,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63863449/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com