rpy import error at Gusty

Bug #128180 reported by sundol
64
Affects Status Importance Assigned to Milestone
rpy (Ubuntu)
Fix Released
Medium
Luca Falavigna
Gutsy
Fix Released
Medium
Luca Falavigna
Hardy
Fix Released
Medium
Luca Falavigna

Bug Description

Binary package hint: python-rpy

"import rpy" of python gives an error

How to reproduce and error message are following
****************

myid@mypc:~$ python
Python 2.5.1 (r251:54863, Jul 17 2007, 15:55:37)
[GCC 4.1.3 20070629 (prerelease) (Ubuntu 4.1.2-13ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
RHOME= /usr/lib/R
RVERSION= 2.5.1
RVER= 2051
RUSER= /home/hckim
Loading Rpy version 2051 ..
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 112, in <module>
    exec("import _rpy%s as _rpy" % RVER)
  File "<string>", line 1, in <module>
ImportError: No module named _rpy2051
>>>

TEST CASE:
1) Install python-rpy
2) Open a terminal and execute python interpreter
3) Launch "import rpy" from python interpreter
4) The above traceback raises

Ankit Jain (luckyankit)
Changed in rpy:
status: New → Confirmed
Revision history for this message
sundol (hyunchul-love-me-deactivatedaccount-deactivatedaccount-deactivatedaccount) wrote :

This bug happens whenever the version of R has been updated with same error message of "No module named _rpy20XX".
I hope that this problem, somehow, will be solved automatically when R has been updated.

Thanks.

Revision history for this message
Luís Figueira (lafig3) wrote :

This bug still exists in the gutsy release version. I've also tried to update R, but without any success. Anybody knows how to fix this?

Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
RHOME= /usr/lib/R
RVERSION= 2.5.1
RVER= 2051
RUSER= /home/luisf
Loading Rpy version 2051 ..
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 112, in <module>
    exec("import _rpy%s as _rpy" % RVER)
  File "<string>", line 1, in <module>
ImportError: No module named _rpy2051

Revision history for this message
sundol (hyunchul-love-me-deactivatedaccount-deactivatedaccount-deactivatedaccount) wrote : Re: [Bug 128180] Re: rpy import error at Gusty

Hi,

It will work with older version of R because gutsy and feisty have _rpy2041
or _rpy2050.
For sure, try "slocate _rpy".
I got
/usr/lib/python2.5/site-packages/_rpy2041.so
/usr/lib/python2.4/site-packages/_rpy2041.so
and you maybe get these, too.
If you get _rpy2041 or _rpy2050, R 2.4.1 or R 2.5.0 will work well,
respectively.

Best,
Hyunchul

On 10/21/07, la-figueira <email address hidden> wrote:
>
> This bug still exists in the gutsy release version. I've also tried to
> update R, but without any success. Anybody knows how to fix this?
>
> Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
> [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import rpy
> RHOME= /usr/lib/R
> RVERSION= 2.5.1
> RVER= 2051
> RUSER= /home/luisf
> Loading Rpy version 2051 ..
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/python2.5/site-packages/rpy.py", line 112, in <module>
> exec("import _rpy%s as _rpy" % RVER)
> File "<string>", line 1, in <module>
> ImportError: No module named _rpy2051
>
> --
> rpy import error at Gusty
> https://bugs.launchpad.net/bugs/128180
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Joel Nelson (joelnn) wrote :

Just adding my vote to get this fixed, I ran into it today

Revision history for this message
Diwaker Gupta (diwaker) wrote :

I can confirm this bug. I tried building from source but that doesn't help much. Does anyone know a fix?

Revision history for this message
Diwaker Gupta (diwaker) wrote :

I found a (temporary) solution:

- Download the sources from rpy.sf.net
- Make sure you have all dependencies installed (sudo apt-get install r-base-dev python-all-dev)
- Modify setup.py, line 132 as follows:
include_dirs = [ os.path.join(RHOME.strip(), 'include'), '/usr/share/R/include/',
- export RHOMES=/usr/lib/R
- run 'python setup.py build'
- copy build/lib.linux-i686-2.5/_rpy2051.so to /usr/lib/python-2.5/site-packages

Thats it!

Revision history for this message
sundol (hyunchul-love-me-deactivatedaccount-deactivatedaccount-deactivatedaccount) wrote :

Thank you. It works!!

Just, here is a correction of single typo-error.
From:
/usr/lib/python-2.5/site-packages
To:
/usr/lib/python2.5/site-packages

On 11/1/07, Diwaker Gupta <email address hidden> wrote:
>
> I found a (temporary) solution:
>
> - Download the sources from rpy.sf.net
> - Make sure you have all dependencies installed (sudo apt-get install
> r-base-dev python-all-dev)
> - Modify setup.py, line 132 as follows:
> include_dirs = [ os.path.join(RHOME.strip(), 'include'),
> '/usr/share/R/include/',
> - export RHOMES=/usr/lib/R
> - run 'python setup.py build'
> - copy build/lib.linux-i686-2.5/_rpy2051.so to /usr/lib/python-2.5
> /site-packages
>
> Thats it!
>
> --
> rpy import error at Gusty
> https://bugs.launchpad.net/bugs/128180
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Martin Saturka (kvutza) wrote :

Another temporary solution is getting the library from the Debian package:
http://packages.debian.org/testing/python/python-rpy

May be, the python-rpy dependences on r-base-core should be with '=='
and not with '>=' specifier.

Revision history for this message
Guy Mauve (cesium5500) wrote :

Same thing... HOPE it will be fix soon, it drive you seek when you spend you spend a whole day trying to make it work instead coding with...

Thanks for all the good Work anyway!

Revision history for this message
Casey Greene (casey-s-greene) wrote :

I just ran into this today too using amd64 gutsy. I'd love to see it fixed. The version from debian is a successful workaround for me.

Revision history for this message
CTW (ctw) wrote :

I have the same problem ... very annoying.

Revision history for this message
Lorenzki (lorenz-gerber) wrote :

Same problem here, on Gutsy.

Revision history for this message
Brandon King (kingb) wrote :

Same problem on Gutsy and it's Jan 9th, 2008... Anyone know why this hasn't been fixed as of yet?

Revision history for this message
Ben Stone (benjamin-stone) wrote :

me too (on gutsy)

Revision history for this message
Green (green-peas) wrote :

In addition to the solution posted by Diwaker Gupta, I found that the source code in rpy.py file needs to be changed:

Specifically, line 168 should be changed from

RException = _rpy.RException

to

RException = _rpy.RPy_RException.

Once this done, open a new python interpreter session and type

import rpy

You should that rpy is loaded without any errors

Revision history for this message
Green (green-peas) wrote :

I meant to type "You should find that rpy is loaded without any errors".

Revision history for this message
nosolosw (nosolosw) wrote :

Like https://bugs.launchpad.net/ubuntu/+source/rpy/+bug/128180/comments/3 (sundol) says ubuntu gutsy haven't _rpy2051. Because this i tried install R 2.5.0 and run it with python 2.5.1 and python-rpy packages... and it goes. Next ones are steps i followed:

 --- 1. Preparing environment:
cd ~/downloads
wget http://cran.es.r-project.org/src/base/R-2/R-2.5.0.tar.gz # download package
sudo apt-get install libxt-dev xorg-dev libX11-dev # install required libraries

 --- 2. Installing R 2.5.0 from sources:

tar -xvvzf R-2.5.0.tar.gz
cd R-2.5.0
./configure --enable-R-shlib
make
make check
make install

 --- 3. Linking RHOME and libraries properly:

export RHOME=/usr/local/bin/R

cd /usr/lib
sudo ln -s ../local/
sudo ln -s ../local/lib/R/lib/libR.so .
sudo ln -s ../local/lib/R/lib/libRblas.so .
sudo ln -s ../local/lib/R/lib/libRlapack.so .

Last step is required because i have two R versions (R 2.5.0 and R 2.5.1). If you don't link to R 2.5.0 version it try to link with R 2.5.1 ... and it doesn't run.

Finally, run python ... and rpy imports! :)

Revision history for this message
Casey Greene (casey-s-greene) wrote :

Can we get the importance of this bumped up? This is obviously annoying a lot of people and there seem to be a number of fixes available for implementation.

Revision history for this message
Gabriel (notelab) wrote :

I would be very grateful if this could be fixed.

Revision history for this message
Greg Detre (greg-gregdetre) wrote :

I'd love to be able to use RPy too, but I'm coming up against the same bug :(

Revision history for this message
Greg Detre (greg-gregdetre) wrote :

Thank you, Diwaker, Sundol and Green! One small note - for the latest version of the source that i downloaded from rpy.sf.net, the line number to change is now 145, not 132. It's easy enough to find - it looks like this:

    else: # unix-like systems, this is known to work for Linux and Solaris
        # include_dirs = [ os.path.join(RHOME.strip(), 'include'),
        # 'src', '/usr/share/R/include' ]
        # modified by gjd as per https://bugs.launchpad.net/ubuntu/+source/rpy/+bug/128180
        include_dirs = [ os.path.join(RHOME.strip(), 'include'), '/usr/share/R/include/',
                         'src', '/usr/share/R/include' ]
        libraries=['R','Rlapack']

Revision history for this message
Iain Russell (irussell30) wrote :

Does anyone know if this has been fixed in the new release "Hardy Heron", 8.04 ? I'm wondering whether to try one of the workarounds already documented, or simply install the beta version of Hardy and see if it works..

Thanks
Iain

Revision history for this message
sundol (hyunchul-love-me-deactivatedaccount-deactivatedaccount-deactivatedaccount) wrote :

It worked well in alpha version but not now in beta version.
I think that they couldn't fix this bug.

_rpy2061.so exists but R version is 2.62 and it produces same error messages.

Hyunchul

On Wed, Mar 26, 2008 at 10:53 PM, Iain Russell <email address hidden> wrote:
> Does anyone know if this has been fixed in the new release "Hardy
> Heron", 8.04 ? I'm wondering whether to try one of the workarounds
> already documented, or simply install the beta version of Hardy and see
> if it works..
>
> Thanks
> Iain
>
>
>
> --
> rpy import error at Gusty
> https://bugs.launchpad.net/bugs/128180
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Iain Russell (irussell30) wrote :

Thanks; in the end I got it to work by building the _rpy2051.so library from source using the steps described by Diwakar Gupta on 31 Oct. 2007.

In the next month or so (when the production release comes out) I will install Hardy which means, I guess, that I'll have to do the same again since it looks like R is at version 2.6.2 but the rpy library for Ubuntu is still at 2.6.1

Thanks for the information...
Iain

Revision history for this message
Allen Riddell (ariddell) wrote :

I'll just confirm that it does indeed exist in hardy beta right now.

Revision history for this message
Sagar Mittal (sagar-mittal) wrote :

This bug is still in Gutsy as of April 11. I've attached a .deb for Python 2.5.1 and R 2.5.1 on amd64.

Revision history for this message
Diwaker Gupta (diwaker) wrote :

Still exists in Hardy Heron. I've filed a new bug report:
https://bugs.launchpad.net/ubuntu/+source/rpy/+bug/223777

Revision history for this message
Javier Rovegno Campos (jrovegno) wrote :

I can confirm this bug on Feisty.
 I've update r from http://cran.r-project.org/bin/linux/ubuntu/
and I get this:

MyUSER@MyHOST:~$ python
Python 2.5.1 (r251:54863, Mar 7 2008, 03:41:45)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
RHOME= /usr/lib/R
RVERSION= 2.7.0
RVER= 2070
RUSER= /home/MyUSER
Loading Rpy version 2070 ..
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 112, in <module>
    exec("import _rpy%s as _rpy" % RVER)
  File "<string>", line 1, in <module>
ImportError: No module named _rpy2070

Changed in rpy:
assignee: nobody → dktrkranz
importance: Undecided → Medium
milestone: none → ubuntu-8.04.1
status: Confirmed → Triaged
Revision history for this message
Javier Rovegno Campos (jrovegno) wrote :

Today I've upgrade python-rpy , r-cran-boot and r-cran-vr from http://cran.r-project.org/bin/linux/ubuntu/
And the problem had solved in Feisty
upgrade python-rpy 1.0~rc1-5 1.0.2-1feisty0
upgrade r-cran-boot 1.2.32-1feisty0 1.2.33-1feisty0
upgrade r-cran-vr 7.2.41-1feisty0 7.2.42-1feisty0

Now I had this results:
$ ls /usr/lib/python2.5/site-packages/_rpy*
/usr/lib/python2.5/site-packages/_rpy2070.so

$ python -c "import rpy"
$

Thanks

Revision history for this message
netzberg (netzberg) wrote :

Similar problem (see below) on Hardy Heron can be resolved by installing the following packages:
http://cran.r-project.org/bin/linux/ubuntu/hardy/r-base-core_2.7.0-1hardy0_i386.deb
http://cran.r-project.org/bin/linux/ubuntu/hardy/python-rpy_1.0.3-1hardy0_i386.deb
(ignore warnings "An older version is available in a software channel")

This will create /usr/lib/python2.5/site-packages/_rpy2070.so which will be accepted by rpy import.

--------------------

The original behaviour:

$ python
Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 134, in <module>
    """ % RVERSION)
RuntimeError: No module named _rpy2062

      RPy module can not be imported. Please check if your rpy
      installation supports R 2.6.2. If you have multiple R versions
      installed, you may need to set RHOME before importing rpy. For
      example:

      >>> from rpy_options import set_options
      >>> set_options(RHOME='c:/progra~1/r/rw2011/')
      >>> from rpy import *

Steve Langasek (vorlon)
Changed in rpy:
milestone: ubuntu-8.04.1 → none
Revision history for this message
Luca Falavigna (dktrkranz) wrote :

Intrepid is already fixed, autosyncs were rebuilt on a up-to-date r-base.
Hardy is affected: a rebuild against r-base 2.6.2-2 will fix this.
Gutsy is affected: a rebuild against r-base 2.5.1-1 will fix this.
Feisty is not affected.
Dapper is not affected.

Changed in rpy:
status: Triaged → Fix Released
assignee: nobody → dktrkranz
importance: Undecided → Medium
status: New → In Progress
assignee: nobody → dktrkranz
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Luca Falavigna (dktrkranz) wrote :

Version 1.0.1-1ubuntu1.1 uploaded to hardy-proposed.
Version 1.0~rc1-6ubuntu0.1 uploaded to gutsy-proposed.

Changed in rpy:
status: In Progress → Confirmed
status: In Progress → Confirmed
Revision history for this message
JamesLavin (james-patriotsbook) wrote : Problem solved! Thank you, Luca!

I've been having this same problem (on Hardy + R 2.6.2), but this new update fixed my problem.

Wonderful.

--James

Revision history for this message
Jonathan Riddell (jr) wrote :

accepted 1.0~rc1-6ubuntu0.1 into gutsy-proposed and 1.0.1-1ubuntu1.1 into hardy-proposed, please test.

description: updated
Changed in rpy:
status: Confirmed → Fix Committed
status: Confirmed → Fix Committed
Revision history for this message
Luca Falavigna (dktrkranz) wrote :

HARDY VERIFICATION

Using version 1.0.1-1ubuntu1 from hardy-release:
Python 2.5.2 (r252:60911, May 7 2008, 15:19:09)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 134, in <module>
    """ % RVERSION)
RuntimeError: No module named _rpy2062
      RPy module can not be imported. Please check if your rpy
      installation supports R 2.6.2. If you have multiple R versions
      installed, you may need to set RHOME before importing rpy. For
      example:
      >>> from rpy_options import set_options
      >>> set_options(RHOME='c:/progra~1/r/rw2011/')
      >>> from rpy import *
>>>

Using version 1.0.1-1ubuntu1.1 from hardy-proposed:
Python 2.5.2 (r252:60911, May 7 2008, 15:19:09)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
>>>

Revision history for this message
Luca Falavigna (dktrkranz) wrote :

GUTSY VERIFICATION

Using version 1.0~rc1-6 from gutsy-release:
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
RHOME= /usr/lib/R
RVERSION= 2.5.1
RVER= 2051
RUSER= /root
Loading Rpy version 2051 ..
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/rpy.py", line 112, in <module>
    exec("import _rpy%s as _rpy" % RVER)
  File "<string>", line 1, in <module>
ImportError: No module named _rpy2051
>>>

Using version 1.0~rc1-6ubuntu0.1 from gutsy-proposed:
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy
RHOME= /usr/lib/R
RVERSION= 2.5.1
RVER= 2051
RUSER= /root
Loading Rpy version 2051 .. Done.
Creating the R object 'r' .. Done
>>>

Revision history for this message
Martin Pitt (pitti) wrote :

Copied to hardy-updates.

Changed in rpy:
status: Fix Committed → Fix Released
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.