[pygtk] problem with starting pygtk inside ipython

John Pye john.pye at student.unsw.edu.au
Wed May 17 11:59:37 WST 2006


Hi all

If I launch ipython using 'ipython -gthread' then type 'import pygtk'
followed by 'pygtk.require('2.0')' then I get an error.

Has anyone else seen this? What is the workaround, if any? Does 'ipython
-gthread' already import pygtk, perhaps?

This effect makes it hard to use existing modules from inside ipython.

Cheers
JP


[john at jdpipe ~]$ ipython -gthread
Python 2.4.1 (#1, May 16 2005, 15:19:29)
Type "copyright", "credits" or "license" for more information.

IPython 0.7.1.fix1 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: import pygtk

In [2]: pygtk.require('2.0')
---------------------------------------------------------------------------
exceptions.AssertionError                            Traceback (most
recent call last)

/home/john/<ipython console>

/usr/src/build/612051-i386/install/usr/lib/python2.4/site-packages/pygtk.py
in require(version)
     67         return
     68
---> 69     assert not sys.modules.has_key('gtk'), \
     70            "pygtk.require() must be called before importing gtk"
     71

AssertionError: pygtk.require() must be called before importing gtk

In [3]:

-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney  NSW 2052  Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/



More information about the pygtk mailing list