Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
Deschamps, Benjamin AGR.GC.CA> writes: > > R.dll is located at C:\Program Files\R\R-2.12.0\bin\i386\R.dll, > and my PATH includes C:\Program Files\R\R-2.12.0, C:\Program Files\R\R-2.12.0 \bin > and C:\Program Files\R\R-2.12.0\bin\i386. I also have the variable R_HOME > defined as C:\Program Files\R\R-2.12.0, and pywin32-214 is installed and working. > Typing “R” at the command prompt works, “R --version” works > and returns the correct version, and “R RHOME” returns C:\PROGA~1\R\R- 2.12~1.0 > (not sure why). By the way, I rpy2 was installed using the current windows > installer, rpy2-2.0.8.win32-py2.6.msi. Thanks, > > > > Benjamin > Has anyone solved this? I lost track of this thread, but now have the same problem. The recommended solution (changes to rinterface\__init__.py) does not work for me. The RPy2 error message I get refers to the proper R.dll path. The rinterface init module throws the error message anyway. The .dll allows all user full control so this should not be a file permission problem with "os.path.exists" -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
On Tue, Nov 2, 2010 at 3:15 PM, John Schroeder wrote: > Deschamps, Benjamin AGR.GC.CA> writes: > > Has anyone solved this? I lost track of this thread, but now have the same > problem. The recommended solution (changes to rinterface\__init__.py) does > not work for me. The RPy2 error message I get refers to the proper R.dll > path. The rinterface init module throws the error message anyway. The .dll > allows all user full control so this should not be a file permission problem > with "os.path.exists" So you tried my suggestions to add os.path.join(R_HOME, 'bin', 'i386', 'R.dll') as a possible location for the DLL to rinterface\__init__.py Could you post the full traceback? Peter -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
Yes, Here is the trace back Traceback (most recent call last): File "E:\Users\roe\Eclipse\workspace\Python\RPy\src\Faithful.py", line 8, in import rpy2.rpy_classic as rpy File "C:\Python26\lib\site-packages\rpy2\rpy_classic.py", line 5, in import rpy2.rinterface as ri File "C:\Python26\lib\site-packages\rpy2\rinterface\__init__.py", line 56, in raise RuntimeError("Unable to locate R.dll within %s" % R_HOME) RuntimeError: Unable to locate R.dll within C:\Program Files\R\R-2.12.0\bin\i386\ Here is the modified content of my __init__.py file. I am assuming I delete the .pyc file to force a new one to be generated. # 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') #Rlib = os.path.join(R_HOME, 'R.dll') # Otherwise fail out! if not os.path.exists(Rlib): raise RuntimeError("Unable to locate R.dll within %s" % R_HOME) win32api.LoadLibrary( Rlib ) Here are key items from my environment Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Co mmon Files\Roxio Shared\DLLShared\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C: \Documents and Settings\roe\Application Data\Python\Scripts;C:\Python26\Scripts; C:\Python26\;C:\MinGW\bin;C:\MinGW\msys\bin;C:\Program Files\R\R-2.12.0\bin\i386 R_HOME=C:\Program Files\R\R-2.12.0\bin\i386\ Here is the location of my R.dll and .exe C:\Program Files\R\R-2.12.0\bin\i386 John A. Schroeder Idaho National Laboratory Battelle Energy Alliance, LLC P.O. Box 1625 Idaho Falls, ID 83415-3850 Ph: 208-526-8755 FAX: 208-526-2930 Peter 11/02/2010 09:48 AM Please respond to rpy-list@lists.sourceforge.net To "RPy help, support and design discussion list" cc Subject Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll On Tue, Nov 2, 2010 at 3:15 PM, John Schroeder wrote: > Deschamps, Benjamin AGR.GC.CA> writes: > > Has anyone solved this? I lost track of this thread, but now have the same > problem. The recommended solution (changes to rinterface\__init__.py) does > not work for me. The RPy2 error message I get refers to the proper R.dll > path. The rinterface init module throws the error message anyway. The .dll > allows all user full control so this should not be a file permission problem > with "os.path.exists" So you tried my suggestions to add os.path.join(R_HOME, 'bin', 'i386', 'R.dll') as a possible location for the DLL to rinterface\__init__.py Could you post the full traceback? Peter -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
OOPs, Looks like it is working if I correct my R_HOME from R_HOME=C:\Program Files\R\R-2.12.0\bin\i386\ to R_HOME=C:\Program Files\R\R-2.12.0 The incorrect R_HOME was a result of an earlier attempt to get this working. Your fix appears to do the job Thankyou! And sorry about the interuption due to a goof on my part! John A. Schroeder Idaho National Laboratory Battelle Energy Alliance, LLC P.O. Box 1625 Idaho Falls, ID 83415-3850 Ph: 208-526-8755 FAX: 208-526-2930 John A Schroeder 11/02/2010 10:04 AM Please respond to "RPy help, support and design discussion list" To rpy-list@lists.sourceforge.net cc Subject Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll Yes, Here is the trace back Traceback (most recent call last): File "E:\Users\roe\Eclipse\workspace\Python\RPy\src\Faithful.py", line 8, in import rpy2.rpy_classic as rpy File "C:\Python26\lib\site-packages\rpy2\rpy_classic.py", line 5, in import rpy2.rinterface as ri File "C:\Python26\lib\site-packages\rpy2\rinterface\__init__.py", line 56, in raise RuntimeError("Unable to locate R.dll within %s" % R_HOME) RuntimeError: Unable to locate R.dll within C:\Program Files\R\R-2.12.0\bin\i386\ Here is the modified content of my __init__.py file. I am assuming I delete the .pyc file to force a new one to be generated. # 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') #Rlib = os.path.join(R_HOME, 'R.dll') # Otherwise fail out! if not os.path.exists(Rlib): raise RuntimeError("Unable to locate R.dll within %s" % R_HOME) win32api.LoadLibrary( Rlib ) Here are key items from my environment Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Co mmon Files\Roxio Shared\DLLShared\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C: \Documents and Settings\roe\Application Data\Python\Scripts;C:\Python26\Scripts; C:\Python26\;C:\MinGW\bin;C:\MinGW\msys\bin;C:\Program Files\R\R-2.12.0\bin\i386 R_HOME=C:\Program Files\R\R-2.12.0\bin\i386\ Here is the location of my R.dll and .exe C:\Program Files\R\R-2.12.0\bin\i386 John A. Schroeder Idaho National Laboratory Battelle Energy Alliance, LLC P.O. Box 1625 Idaho Falls, ID 83415-3850 Ph: 208-526-8755 FAX: 208-526-2930 Peter 11/02/2010 09:48 AM Please respond to rpy-list@lists.sourceforge.net To "RPy help,support and design discussion list" cc Subject Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll On Tue, Nov 2, 2010 at 3:15 PM, John Schroeder wrote: > Deschamps, Benjamin AGR.GC.CA> writes: > > Has anyone solved this? I lost track of this thread, but now have the same > problem. The recommended solution (changes to rinterface\__init__.py) does > not work for me. The RPy2 error message I get refers to the proper R.dll > path. The rinterface init module throws the error message anyway. The .dll > allows all user full control so this should not be a file permission problem > with "os.path.exists" So you tried my suggestions to add os.path.join(R_HOME, 'bin', 'i386', 'R.dll') as a possible location for the DLL to rinterface\__init__.py Could you post the full traceback? Peter -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. an
Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
On Tue, Nov 2, 2010 at 4:11 PM, John A Schroeder wrote: > > OOPs, > > > Looks like it is working if I correct my R_HOME from > > R_HOME=C:\Program Files\R\R-2.12.0\bin\i386\ > > to > > R_HOME=C:\Program Files\R\R-2.12.0 > > The incorrect R_HOME was a result of an earlier attempt to get this working. > Your fix appears to do the job > > Thankyou! Well spotted - I was just writing a reply to clarify if you'd set R_HOME like that. I'm glad the fix works - Laurent, can you apply this to the repository? Peter -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] rpy2 2.0.8 win32 Unable to locate R.dll
On 02/11/10 17:22, Peter wrote: > On Tue, Nov 2, 2010 at 4:11 PM, John A Schroeder > wrote: >> OOPs, >> >> >> Looks like it is working if I correct my R_HOME from >> >> R_HOME=C:\Program Files\R\R-2.12.0\bin\i386\ >> >> to >> >> R_HOME=C:\Program Files\R\R-2.12.0 >> >> The incorrect R_HOME was a result of an earlier attempt to get this working. >> Your fix appears to do the job >> >> Thankyou! > Well spotted - I was just writing a reply to clarify if you'd set R_HOME like > that. I'm glad the fix works - Laurent, can you apply this to the repository? > Thanks for the patch Peter. I just pushed to the branch "version_2.0.x", entry 1326:4af6fc146f3. Someone will have to contribute the binary builds. I have not bothered to apply to other branches. Laurent > Peter > > -- > Nokia and AT&T present the 2010 Calling All Innovators-North America contest > Create new apps& games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > ___ > rpy-list mailing list > rpy-list@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rpy-list -- Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev ___ rpy-list mailing list rpy-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rpy-list
Re: [Rpy] converting r array to numpy array
Thanks Laurent, that makes sense. I noticed someone reported this problem earlier (I probably should have looked there first!), but didn't follow it up so their issue got closed. I reopened it, hope that's ok. See issue #47 rpy2 -> numpy mangles arrays. Thanks again, Robert -Original Message- From: Laurent Gautier [mailto:lgaut...@gmail.com] Sent: Tuesday, 2 November 2010 4:49 PM To: Denham Robert Cc: RPy help, support and design discussion list Subject: Re: [Rpy] converting r array to numpy array This is a bug then. The problem is in the way strides are computed (buffer.c in rpy/rinterface), and a fix seems to be: static void sexp_strides(SEXP sexp, Py_intptr_t *strides, Py_ssize_t itemsize, Py_intptr_t *shape, int nd) { /* Set the buffer 'strides', that is a vector or Py_intptr_t * containing the offset (in bytes) when progressing along * each dimension. */ int i; Py_intptr_t cumul_strides = 1; strides[0] = itemsize; for (i = 1; i < nd; i++) { strides[i] = shape[i-1] * strides[i-1]; } } I just committed that change to the branch 2.2.x. but I'd like to have this tested a little before porting it back to 2.1.x. Can you fill one on the bitbucket tracker ? (so others know about the issue) Thanks, L. On 01/11/10 22:36, Denham Robert wrote: > Yeah, sorry, this is the output: > In [3]: import numpy > In [4]: import rpy2 > In [5]: import rpy2.robjects as robjects In [7]: marr = > robjects.r.array(robjects.IntVector(range(54)),dim= > robjects.IntVector([9,2,3])) > > In [8]: marrpy = numpy.array(marr) > In [9]: print marrpy.flatten() > --> print(marrpy.flatten()) > [ 0 2 4 9 11 13 1 3 5 10 12 14 2 4 6 11 13 15 3 5 7 12 14 > 16 > 4 >6 8 13 15 17 5 7 9 14 16 18 6 8 10 15 17 19 7 9 11 16 18 20 > 8 10 > 12 17 19 21] > > In [10]: print robjects.r['as.vector'](marr) > ---> print(robjects.r['as.vector'](marr)) > [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 > 21 > 22 23 24 > [26] 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 > 47 48 49 > [51] 50 51 52 53 > > > In [15]: print marrpy.flatten('F') > ---> print(marrpy.flatten('F')) > [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 2 3 4 5 6 > 7 > 8 >9 10 11 12 13 14 15 16 17 18 19 4 5 6 7 8 9 10 11 12 13 14 15 > 16 > 17 > 18 19 20 21] > > > I was prepared for differences due to column/row ordering, but this > doesn't seem to be the problem. > > Works fine on matrices: > > In [11]: mat = robjects.r.matrix(robjects.IntVector(range(54)),nrow=9) > In [12]: matpy = numpy.array(mat) > In [13]: print mat > ---> print(mat) >[,1] [,2] [,3] [,4] [,5] [,6] > [1,]09 18 27 36 45 > [2,]1 10 19 28 37 46 > [3,]2 11 20 29 38 47 > [4,]3 12 21 30 39 48 > [5,]4 13 22 31 40 49 > [6,]5 14 23 32 41 50 > [7,]6 15 24 33 42 51 > [8,]7 16 25 34 43 52 > [9,]8 17 26 35 44 53 > > > In [14]: print matpy > ---> print(matpy) > [[ 0 9 18 27 36 45] > [ 1 10 19 28 37 46] > [ 2 11 20 29 38 47] > [ 3 12 21 30 39 48] > [ 4 13 22 31 40 49] > [ 5 14 23 32 41 50] > [ 6 15 24 33 42 51] > [ 7 16 25 34 43 52] > [ 8 17 26 35 44 53]] > > > > Regards, Robert > > > > -Original Message- > From: Laurent Gautier [mailto:lgaut...@gmail.com] > Sent: Monday, 1 November 2010 4:58 PM > To: Denham Robert > Cc: RPy help, support and design discussion list > Subject: Re: [Rpy] converting r array to numpy array > > On 01/11/10 07:28, Denham Robert wrote: >> I got caught out converting a 3d array in R to a numpy array. I did >> something like: >> >> import numpy >> import rpy2 >> import rpy2.robjects as robjects >> >> marr = robjects.r.array(robjects.IntVector(range(54)),dim= >> robjects.IntVector([9,2,3])) >> marrpy = numpy.array(marr) >> print marrpy.flatten() >> print robjects.r['as.vector'](marr) >> >> Which clearly doesn't work (at least for me, using rpy2.1.7, R-10.0 >> on 64bit suse linux). > Could you be more specific about "does not work" ? > If you are after getting the same output for the two print calls, this > is not happening because arrays are being stored "column-major" by R > by while numpy has "row-major" as a default. > Try: > > print marrpy.flatten('F') > > > >>The matrix version does work, eg >> >> mat = robjects.r.matrix(robjects.IntVector(range(54)),nrow=9) >> matpy = numpy.array(mat) >> print mat >> print matpy >> >> I checked the documentation, and found examples for vectors and >> matrices, but not for arrays, but also no warnings. So, I was just >> wondering, is this supposed to work? If it is, a hint on why it >> doesn't work for me would be good. If it isn't supposed to work, I >> was wondering if it were possible to throw an error or something. > > It is supposed to work, but not claim about an absence of bugs is made. > > > Bes