ImportError: Bad magic number

Hans Nowak wurmy at earthlink.net
Wed Jan 9 11:21:09 EST 2002


scli wrote:

> 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.

This happens when you have a .pyc file that was compiled by a
different version from the Python you are trying to import
it with. Normally, if the corresponding .py file is around,
this is not a problem, because Python will automatically
recompile and produce a new .pyc file. So it seems that
you don't have the original .py file around here, or it
cannot be recompiled for some reason. (If they are both
present, you could try removing that .pyc file.)

Or you can try to find out what Python version is used, and
install that version... 

--Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==') 
       # decode for email address ;-)
Site:: http://www.awaretek.com/nowak/



More information about the Python-list mailing list