ImportError: Bad magic number

scli sc_li at hongkong.com
Wed Jan 9 10:33:14 EST 2002


Dear all,

I have installed python and i would like to use gtk. The following
helloworld program was used.

from gtk import *

def hello_cb(button):
	print "Hello World"
	window.destroy()

window = GtkWindow(WINDOW_TOPLEVEL) # create a top level window
window.connect("destroy", mainquit) # quit the event loop on destruction
window.set_border_width(10)         # set padding round child widget

button = GtkButton("Hello World")
button.connect("clicked", hello_cb) # call hello_cb when clicked
window.add(button)                  # add button to window
button.show()                       # show button

window.show()
mainloop()                          # enter the main event loop

after typing "python hello.py"
it returns
"Traceback (most recent call last):
File "hello.py", line, in ?
from gtk import *
ImportError: Bad magic number in /usr/lib/python2.1/site-packages/gtk.pyc"

What can i do to solve that problem? Thanks a lot.






More information about the Python-list mailing list