You are not logged in.
Hi guys,
I'm new to both Python and PyGTK, just writing a Hello World program in PyGTK and I'm getting the following error:
Traceback (most recent call last):
File "./pygtk.py", line 3, in <module>
import pygtk
File "/home/dave/chirrup/pygtk.py", line 4, in <module>
pygtk.require('2.0')
AttributeError: 'module' object has no attribute 'require'
It's choking on:
pygtk.require('2.0')
It works when i remove the offending line, but what exactly is wrong with this line? It's in every PyGTK demonstration I've seen, and Googling this error has only confused me.
Help really appreciated, cheers!
Offline
?
In [1]: import pygtk
In [2]: pygtk.
pygtk.__all__ pygtk.__file__ pygtk.__new__ pygtk.__sizeof__ pygtk._pygtk_dir_pat pygtk.require20
pygtk.__builtins__ pygtk.__format__ pygtk.__package__ pygtk.__str__ pygtk._pygtk_required_version pygtk.sys
pygtk.__class__ pygtk.__getattribute__ pygtk.__reduce__ pygtk.__subclasshook__ pygtk.fnmatch
pygtk.__delattr__ pygtk.__hash__ pygtk.__reduce_ex__ pygtk._get_available_versions pygtk.glob
pygtk.__dict__ pygtk.__init__ pygtk.__repr__ pygtk._our_dir pygtk.os
pygtk.__doc__ pygtk.__name__ pygtk.__setattr__ pygtk._pygtk_2_0_dir pygtk.require
In [2]: pygtk.re
pygtk.require pygtk.require20
In [2]: pygtk.require
Out[2]: <function require at 0xe98c80>
Cthulhu For President!
Offline
OH I see. Look, it's not importing the right pygtk. You have a file called pygtk.py higher up the path..."/home/dave/chirrup/pygtk.py"
Cthulhu For President!
Offline
Oh, hell, that was one stupid mistake.
Apparently naming your files the same as the ones you're trying to import isn't big or clever...
*shamed*
Cheers for the help!
Offline
Oh, hell, that was one stupid mistake.
Apparently naming your files the same as the ones you're trying to import isn't big or clever...
The new relative/absolute import syntax is designed to overcome this problem:
http://www.python.org/dev/peps/pep-0328/
Renaming the module is probably smartest in your case, but its something to be aware of. :-)
Dusty
Offline