Bad magic no. in python zipfile

Peter Hansen peter at engcorp.com
Wed Oct 12 22:36:36 EDT 2005


stewart.midwinter at gmail.com wrote:
\> I'm able to create a new zipfile with the module's ZipFile class and
> add files to it.  After closing the file, I'm able to view the contents
> of it with WinZip.  I can also confirm that it is a python zip file by
> using the is_zipfile() method.  All good so far.  However, under some
> circumstances, I am unable to later read the file and extract its
> contents.  As soon as a I attempt to instantiate a new ZipFile
> instance, I receive an error regarding Bad Magic number.   In the past,
> I've seen that when trying to use a .pyc module, created with one
> Python version, using another Python version.  But in this case, I
> created the zip file under Python 2.4.2 and tried to open it under
> Python 2.4.2 as well.  Any ideas on what to do?  

Maybe try posting the full traceback so we can see the "Bad Magic 
Number" error you are getting...

-Peter



More information about the Python-list mailing list