Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
124 views
in Technique[技术] by (71.8m points)

python - R_HOME Error with rpy2

I know there are quite a few posts on getting up and running with rpy2 on windows 7 32 bit. I have referenced a good number of them and attempted their solutions, including the use of PypeR.

I dont explicitly have a R_HOME variable set in my path, but per this question, I confirmed that R is in my PATH (I can type R at the command line and get R to run) and even copied all of the files from the i386 folder to the parent bin folder.

My issue is pasted below. Any thoughts?

In [5]: from rpy2 import robjects
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-1f019d00d232> in <module>()
----> 1 from rpy2 import robjects

C:Anacondalibsite-packages
py2
objects\__init__.py in <module>()
     16 import rpy2.rlike.container as rlc
     17
---> 18 from rpy2.robjects.robject import RObjectMixin, RObject
     19 from rpy2.robjects.vectors import *
     20 from rpy2.robjects.functions import Function, SignatureTranslatedFunction

C:Anacondalibsite-packages
py2
objects
object.py in <module>()
      3 import rpy2.rinterface
      4
----> 5 rpy2.rinterface.initr()
      6
      7 import conversion

RuntimeError: R_HOME not defined.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I confirm this issue is related to R_HOME variable not defined.

In my opinion, all of these issues are caused because the developers of rpy2 package haven't documented properly the requirements of their software:

  • Install R
  • Create R_HOME system variable
  • Add R_HOMEin to the PATH, in order to execute R from python
  • Add R_HOMEinx64 to the PATH, in order to load R.dll
  • Install package tzlocal

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...