Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36575 > unrolled thread

problems importing from /usr/lib/pyshared/

Started byHarold <dadapapa@googlemail.com>
First post2013-01-10 08:20 -0800
Last post2013-01-12 08:45 -0800
Articles 4 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  problems importing from /usr/lib/pyshared/ Harold <dadapapa@googlemail.com> - 2013-01-10 08:20 -0800
    Re: problems importing from /usr/lib/pyshared/ Dieter Maurer <dieter@handshake.de> - 2013-01-12 08:08 +0100
      Re: problems importing from /usr/lib/pyshared/ Harold <dadapapa@googlemail.com> - 2013-01-12 08:45 -0800
      Re: problems importing from /usr/lib/pyshared/ Harold <dadapapa@googlemail.com> - 2013-01-12 08:45 -0800

#36575 — problems importing from /usr/lib/pyshared/

FromHarold <dadapapa@googlemail.com>
Date2013-01-10 08:20 -0800
Subjectproblems importing from /usr/lib/pyshared/
Message-ID<e4ea45de-27ee-4531-bcb8-46d6c8846d80@googlegroups.com>
Dear all,

I recently upgraded my system from ubuntu 11.4 to 12.4 and since run into an issue when trying to import several packages in python2.7, e.g.

harold@ubuntu:~$ python -c 'import gtk'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py", line 30, in <module>
    import gobject as _gobject
  File "/usr/share/pyshared/gobject/__init__.py", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "/usr/share/pyshared/glib/__init__.py", line 22, in <module>
    from glib._glib import *
ImportError: No module named _glib

the same, for example, with pysvn:

harold@ubuntu:~$ python -c 'import pysvn'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/pyshared/pysvn/__init__.py", line 99, in <module>
    import _pysvn_2_7
ImportError: No module named _pysvn_2_7

After playing around a bit, I realized that I can import said packages without problems, if I delete /usr/lib/pyshared from the python path:

>>> import sys
>>> sys.path
['', '/usr/share/pyshared', '/home/harold', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
>>> del sys.path[1]
>>> import gtk
>>> import pysvn
>>> 

Is /usr/lib/pyshared supposed to be in the python path? If not, how can I ensure that it is not included? Where is PYTHONPATH initialized by default, anyway?

Thanks, harold.

[toc] | [next] | [standalone]


#36684

FromDieter Maurer <dieter@handshake.de>
Date2013-01-12 08:08 +0100
Message-ID<mailman.435.1357974522.2939.python-list@python.org>
In reply to#36575
Harold <dadapapa@googlemail.com> writes:

> I recently upgraded my system from ubuntu 11.4 to 12.4 and since run into an issue when trying to import several packages in python2.7, e.g.
>
> harold@ubuntu:~$ python -c 'import gtk'
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py", line 30, in <module>
>     import gobject as _gobject
>   File "/usr/share/pyshared/gobject/__init__.py", line 26, in <module>
>     from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
>   File "/usr/share/pyshared/glib/__init__.py", line 22, in <module>
>     from glib._glib import *
> ImportError: No module named _glib

Ubuntu 12 has introduced important changes with respect to "glib" (and
depending packages). In fact, there are now two quite incompatible
implementations - the old "static" one and a new "dynamic" one.
It looks as if in your case, old and new implementations were mixed.

I had a similar problem when upgrading to "Ubuntu 12.4". In my case,
it turned out that my (custom) "PYTHONPATH" setting was responsible for
getting into the incompatibility.


The new way to use "gtk" is via the "gi" (probable "gnome interface")
module. It looks like:

from gi.repository import Gtk,GdkPixbuf,GObject,Pango,Gdk,Gio

[toc] | [prev] | [next] | [standalone]


#36709

FromHarold <dadapapa@googlemail.com>
Date2013-01-12 08:45 -0800
Message-ID<c4328641-66a4-4836-8504-b427c51b4791@googlegroups.com>
In reply to#36684
Thank you Dieter,

> Ubuntu 12 has introduced important changes with respect to "glib" (and
> depending packages). In fact, there are now two quite incompatible
> implementations - the old "static" one and a new "dynamic" one.
> It looks as if in your case, old and new implementations were mixed.
> 
> I had a similar problem when upgrading to "Ubuntu 12.4". In my case,
> it turned out that my (custom) "PYTHONPATH" setting was responsible for
> getting into the incompatibility.
> 
> The new way to use "gtk" is via the "gi" (probable "gnome interface")
> module. It looks like:
>
> from gi.repository import Gtk,GdkPixbuf,GObject,Pango,Gdk,Gio

I will investigate this gi module. As for my import problem, it turned out that it was my own fault: following some recommendation on the web, I had added /usr/share/pyshared to the python path in ~/.profile and forgot to log out and in again after undoing this change. Everything works fine again, and I am ready to explore the new modules.

[toc] | [prev] | [next] | [standalone]


#36710

FromHarold <dadapapa@googlemail.com>
Date2013-01-12 08:45 -0800
Message-ID<mailman.452.1358009705.2939.python-list@python.org>
In reply to#36684
Thank you Dieter,

> Ubuntu 12 has introduced important changes with respect to "glib" (and
> depending packages). In fact, there are now two quite incompatible
> implementations - the old "static" one and a new "dynamic" one.
> It looks as if in your case, old and new implementations were mixed.
> 
> I had a similar problem when upgrading to "Ubuntu 12.4". In my case,
> it turned out that my (custom) "PYTHONPATH" setting was responsible for
> getting into the incompatibility.
> 
> The new way to use "gtk" is via the "gi" (probable "gnome interface")
> module. It looks like:
>
> from gi.repository import Gtk,GdkPixbuf,GObject,Pango,Gdk,Gio

I will investigate this gi module. As for my import problem, it turned out that it was my own fault: following some recommendation on the web, I had added /usr/share/pyshared to the python path in ~/.profile and forgot to log out and in again after undoing this change. Everything works fine again, and I am ready to explore the new modules.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web