Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Zipfile - Invalid Argument Errno 22
    primarykey
    data
    text
    <p>I have a .zip file and would like to know the names of the files within it. Here's the code:</p> <pre><code>zip_path = glob.glob(path + '/*.zip')[0] file = open(zip_path, 'r') # opens without error if zipfile.is_zipfile(file): print str(file) # prints to console my_zipfile = zipfile.ZipFile(zip_path) # throws IOError </code></pre> <p>Here is the traceback:</p> <pre><code>&lt;open file u'/Users/me/Documents/project/uploads/assets/peter/offline_message/offline_imgs.zip', mode 'r' at 0x107b2a150&gt; Traceback (most recent call last): File "/Users/me/Documents/project/admin_dev/proj_name/views.py", line 1680, in get_dps_app_builder_assets link_to_assets_zip = zip_dps_app_builder_assets(server_url, app_slug, button_slugs) File "/Users/me/Documents/project/admin_dev/proj_name/views.py", line 1724, in zip_dps_app_builder_assets my_zipfile = zipfile.ZipFile(zip_path) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 712, in __init__ self._GetContents() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 746, in _GetContents self._RealGetContents() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 779, in _RealGetContents fp.seek(self.start_dir, 0) IOError: [Errno 22] Invalid argument </code></pre> <p>I am very confused as to why this is happening since the file is clearly there and is a valid .zip file. The documentation clearly states that you can pass it either the path to the file or a file-like object, neither of which work in my case:</p> <p><a href="http://docs.python.org/2/library/zipfile#zipfile-objects" rel="nofollow">http://docs.python.org/2/library/zipfile#zipfile-objects</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload