[Feisty] Can't import python module

Bug #74956 reported by Jan Mynarik
8
Affects Status Importance Assigned to Milestone
python-defaults (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Some programs do not run because they can't import various 3rd party (not python core) module(s). It differs with the version of python. If it doesn't work with python2.4, it works with python2.5. And vice-versa.

Programs I tried and don't work with python2.4 (and do work with 2.5): freeloader, gnome-btdownload
Don't work with python2.5 (and do work with 2.4): deskbar, service-discovery-applet, apport

Revision history for this message
Matthias Klose (doko) wrote :

please be more specific ("does not work" is not helpful) and support a separate report for each problem.

Usually the interpreter for an application is hardcoded. you cannot change it deliberately.

Changed in python-defaults:
assignee: nobody → doko
status: Unconfirmed → Needs Info
Revision history for this message
Jan Mynarik (jan-mynarik) wrote :

I wrote "can't import module" and that is exactly the problem (only module names differ for different programs), e.g.

Traceback (most recent call last):
  File "/usr/bin/command-not-found", line 8, in <module>
    from CommandNotFound import CommandNotFound
ImportError: No module named CommandNotFound

I can change the interpreter by changing /usr/bin/python symbolic link to either python2.4 or python2.5. I did this hack because I really needed to run something (can't remember now) that didn't work with default python (set to 2.4).

Revision history for this message
chantra (chantra) wrote :

in my case, I can reproduce the bug with gnome-btdownload
but it does not work with either python2.4 nor python2.5

the reason is that python path is not set to go and look in any /usr/share/python-support/* directories.

patching gnome-btdownload with the attach patch will make it works.
Okie, the patch is not related to the bug, but it might help understanding what is going wrong

Revision history for this message
chantra (chantra) wrote :

module not found such as (gnome-btdownload case):
$ gnome-btdownload
Traceback (most recent call last):
  File "/usr/bin/gnome-btdownload", line 4, in ?
    import BitTorrent.download, BitTorrent.bencode
ImportError: No module named BitTorrent.download

Changed in python-defaults:
status: Needs Info → Confirmed
Simon Law (sfllaw)
Changed in python-defaults:
status: Confirmed → Needs Info
chantra (chantra)
Changed in python-defaults:
assignee: doko → nobody
status: Needs Info → Confirmed
Revision history for this message
Jan Mynarik (jan-mynarik) wrote :

It is probably problem in individual python applications, although present in many. See bug report with solution for bittorrent here:
https://bugs.launchpad.net/distros/ubuntu/+source/bittorrent/+bug/75672

Revision history for this message
chantra (chantra) wrote :

since upgrade to python* 2.5-5ubuntu4, this bug does not seem to happen anymore.
Closing it as "fix released"

Changed in python-defaults:
status: Confirmed → Fix Released
Revision history for this message
Samuli Lager (samuli-lager) wrote :

I got still this problem:

~
22:06:41 <samuli@samuli-desktop> python --version
Python 2.5

~
22:06:44 <samuli@samuli-desktop> python
Python 2.5 (release25-maint, Mar 15 2007, 10:53:31)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/socket.py", line 3, in <module>

TypeError: 'module' object is not callable

Revision history for this message
Matthias Klose (doko) wrote :

Samuli, it's very strange that a standard module cannot be imported; please could you recheck with a current feisty live CD?

Revision history for this message
Samuli Lager (samuli-lager) wrote : Re: [Bug 74956] Re: [Feisty] Can't import python module

I dont have the live CD, and have no energy to make one. Sorry.

If i try python2.4:

12:16:54 <samuli@samuli-desktop> python2.4
Python 2.4.4 (#2, Mar 7 2007, 19:12:09)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: Bad magic number in socket.pyc
>>>

2007/3/21, Matthias Klose <email address hidden>:
> Samuli, it's very strange that a standard module cannot be imported;
> please could you recheck with a current feisty live CD?
>
> --
> [Feisty] Can't import python module
> https://launchpad.net/bugs/74956
>

--
Terveisin Samuli Lager

Revision history for this message
Samuli Lager (samuli-lager) wrote :

This is really strange. I made another user and tryed and it worked.

2007/3/21, Samuli Lager <email address hidden>:
> I dont have the live CD, and have no energy to make one. Sorry.
>
> If i try python2.4:
>
> 12:16:54 <samuli@samuli-desktop> python2.4
> Python 2.4.4 (#2, Mar 7 2007, 19:12:09)
> [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import socket
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> ImportError: Bad magic number in socket.pyc
> >>>
>
>
>
> 2007/3/21, Matthias Klose <email address hidden>:
> > Samuli, it's very strange that a standard module cannot be imported;
> > please could you recheck with a current feisty live CD?
> >
> > --
> > [Feisty] Can't import python module
> > https://launchpad.net/bugs/74956
> >
>
>
> --
> Terveisin Samuli Lager
>

--
Terveisin Samuli Lager

Revision history for this message
Samuli Lager (samuli-lager) wrote :

Got it! I had a socket.pyc in my ~/ and that messed things up.

2007/3/21, Samuli Lager <email address hidden>:
> This is really strange. I made another user and tryed and it worked.
>
> 2007/3/21, Samuli Lager <email address hidden>:
> > I dont have the live CD, and have no energy to make one. Sorry.
> >
> > If i try python2.4:
> >
> > 12:16:54 <samuli@samuli-desktop> python2.4
> > Python 2.4.4 (#2, Mar 7 2007, 19:12:09)
> > [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import socket
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > ImportError: Bad magic number in socket.pyc
> > >>>
> >
> >
> >
> > 2007/3/21, Matthias Klose <email address hidden>:
> > > Samuli, it's very strange that a standard module cannot be imported;
> > > please could you recheck with a current feisty live CD?
> > >
> > > --
> > > [Feisty] Can't import python module
> > > https://launchpad.net/bugs/74956
> > >
> >
> >
> > --
> > Terveisin Samuli Lager
> >
>
>
> --
> Terveisin Samuli Lager
>

--
Terveisin Samuli Lager

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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