简体   繁体   中英

Shutil unpack archive - Can not unpack temporary zip file - Python

I am trying to download a zip file from the cloud storage in the following manner:


import shutil 

  with tempfile.NamedTemporaryFile(suffix=".zip") as source_zip:
    aws_util.download(my_buicket, "my_folder/design.zip", source_zip)
    shutil.unpack_archive(source_zip.name, "myfile", "zip")

While trying to unpack the temporary zip file created in the step above. I am getting the following error:

shutil.ReadError: C:\Users\ryan.zhu\AppData\Local\Temp\tmppnn80v56.zip is not a zip file

I am using windows OS.

How to solve it. Thanks

It is possible, that given file does not even exist and given error message is only making you think, that given file is somehow wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM