Peter <rpy-list <at> maubp.freeserve.co.uk> writes:
> Try adding these two lines to rinterface/__init__.py
>
> # Load the R dll using the explicit path
> # First try the bin dir:
> Rlib = os.path.join(R_HOME, 'bin', 'R.dll')
> # Try bin/i386 subdirectory seen in R 2.12.0 ## ADDED ##
> if not os.path.exists(Rlib): ## ADDED ##
> Rlib = os.path.join(R_HOME, 'bin', 'i386', 'R.dll') ## ADDED ##
> # Then the lib dir:
> if not os.path.exists(Rlib):
> Rlib = os.path.join(R_HOME, 'lib', 'R.dll')
> # Otherwise fail out!
> if not os.path.exists(Rlib):
> raise RuntimeError("Unable to locate R.dll within %s" % R_HOME)
Thanks a lot for this! I needed to hack this a bit further to make it work, and
describe my workaround for posteriority.
As of R 2.12.0 on Windows, "There are two versions of the R executable in
R-2.12.0\bin\i386 (32-bit) or R-2.12.0\bin\x64 (64-bit)."
http://cran.uib.no/bin/windows/base/README.R-2.12.0
During installation I opted to install both the 32- and 64-bit version of R.
Most packages work with the 64-bit version, but some don't. So I wanted to
install rpy2 (and rnumpy, a little gem at http://bitbucket.org/njs/rnumpy/wiki/
API, see also the "IPython integration" part) on the 32-bit version of R on my
system.
This required a further hack to rinterface/__init__.py. Immediately before the
lines of Peter's code, replace
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'lib')
with
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin', 'i386')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules', 'i386')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'library')
For compatibility with previous versions, it would probably be good to check
for R < 2.12 (e.g. whether os.path.join(R_HOME, 'lib') exists) and use the new
lines if it doesn't. Untested:
if os.path.exists(os.path.join(R_HOME, 'lib'):
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'lib')
else:
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'bin', 'i386')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'modules', 'i386')
os.environ['PATH'] += ';' + os.path.join(R_HOME, 'library')
Windows 7 64-bit, Python 2.6.5 |EPD 6.2-2 (32-bit), rpy2 2.0.8, R version
2.12.0 (2010-10-15)
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list