rpy import error at Gusty

Bug #128180 reported by sundol on 2007-07-25
64
Affects Status Importance Assigned to Milestone
rpy (Ubuntu)
Medium
Luca Falavigna
Gutsy
Medium
Luca Falavigna
Hardy
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) on 2007-09-17
Changed in rpy:
status: New → Confirmed

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.

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

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.
>

Joel Nelson (joelnn) wrote :

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

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?

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!

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.
>

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.

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!

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.

CTW (ctw) wrote :

I have the same problem ... very annoying.

Lorenzki (lorenz-gerber) wrote :

Same problem here, on Gutsy.

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?

Ben Stone (benjamin-stone) wrote :

me too (on gutsy)

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

Green (green-peas) wrote :

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

amaneiro (amaneiro) 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! :)

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.

Gabriel (notelab) wrote :

I would be very grateful if this could be fixed.

Greg Detre (greg-gregdetre) wrote :

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

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']

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

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.
>

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

Allen Riddell (ariddell) wrote :

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

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.

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

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

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

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) on 2008-06-05
Changed in rpy:
milestone: ubuntu-8.04.1 → none
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
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

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

Wonderful.

--James

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
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
>>>

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
>>>

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  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers