Bad magic number?

Tim Peters tim.one at home.com
Mon May 7 06:52:54 CEST 2001


[Volucris]
> The following error happens when importing mp3scan.py:
> ...
> Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
> >>> import mp3scan
> ...
> ImportError: Bad magic number in
> C:\Python20\mp3scan.pyc
> >>>

Note that it's complaining about a .pyc file, not a .py file.  Delete the
.pyc file and try again.

> ...
> I e-mailed him the pyc. Anyone know what a 'magic number' is?

In this case it's catching that the user is trying to run a .pyc file under a
version of Python it can't be run under.  As you said later:

> Also, the pyc was created with Python 2.1

Programs compiled by 2.1 may use features that an eariler interpreter (like
the 2.0 at the start of your first msg) has no idea what to do with.  So each
version of Python puts a unique "magic number" in the .pyc files it
generates, and when Python runs a .pyc file it first checks to see that the
magic number within it matches what it expects.

Send your friend a .py file instead.





More information about the Python-list mailing list