469,955 Members | 1,412 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,955 developers. It's quick & easy.

Error from zipfile

Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile. I've tried adding the flag to allow 64 bit and even using
uncompressed zip files. Niether fixes the problem.

The zip file and contents were created on linux. To be certain that
was not the issue I have emptied the zip file, created a new one,
opend all the files in wordpad and saved them, then put the contents
into the new file. Still no joy.

Any help would be greatly appreciated. On linux I'm running python 2.5
and on windows it is 2.4.

Thanks,

Wesley Brooks.
Jul 1 '08 #1
2 1211
On Tue, 01 Jul 2008 16:38:23 +0100, Wesley Brooks wrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, […]
Are you sure you read and save the file in binary mode, especially on
windows!?

Ciao,
Marc 'BlackJack' Rintsch
Jul 1 '08 #2
On Jul 2, 1:38 am, "Wesley Brooks" <wesbro...@gmail.comwrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile.
If "saved as per usual" means something like open('foo.zip',
'w').write(the_string) then this is highly likely to be your
problem. Use 'wb'. Get into the habit of using the 'b' flag on
binary files in your scripts (whether reading or writing) and they'll
be much more portable.

Something to check: on the Linux side, do
wc -l foo.zip
(that option's 'L'.lower()) to get the number of pseudo-lines in your
zip file, and compare the sizes of the file on Linux and Windows. What
do you see?

HTH,
John
Jul 1 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Tung Wai Yip | last post: by
1 post views Thread by LC | last post: by
19 posts views Thread by Gerson Kurz | last post: by
reply views Thread by Ian Cook | last post: by
1 post views Thread by Waitman Gobble | last post: by
5 posts views Thread by Waguy | last post: by
11 posts views Thread by Hari Sekhon | last post: by
5 posts views Thread by OriginalBrownster | last post: by
8 posts views Thread by =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post: by
3 posts views Thread by towers | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.