Search code examples
pythonzipunzippython-zipfile

Extract a zip file in python [zip file contains .img file in it, and zipfile gets stuck]


I am trying to extract a .zip file using python. I am doing it as:

z = zipfile.ZipFile(file_name)
for f in z.namelist():
    print f
    if f.endswith('/'):
        os.makedirs(f)
    else:
        z.extract(f)

This works fine until the .img file is encountered. Once .img is encountered the extract freezes!

How to resolve this?


Solution

  • z = zipfile.ZipFile(file_name)
    z.extractall()