简体   繁体   English

Shutil 解压存档 - 无法解压临时 zip 文件 - Python

[英]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:我正在尝试通过以下方式从云存储中下载一个 zip 文件:


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.在尝试解压缩在上述步骤中创建的临时文件 zip 时。 I am getting the following error:我收到以下错误:

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

I am using windows OS.我正在使用 windows 操作系统。

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.有可能,给定的文件甚至不存在,给定的错误消息只是让你认为,给定的文件在某种程度上是错误的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 system.string 数据类型解压缩为 kql 中的扁平字符串 - how to unpack a system.string data type into a flat string in kql “错误的处理程序‘lambda_handler’:没有足够的值来解压(预期 2,得到 1)”, - "Bad handler 'lambda_handler': not enough values to unpack (expected 2, got 1)", 是否可以使用 cli 工具在 .zip 压缩标准输入到标准 output 中指定一个文件名? - Is it possible to specify a file name inside .zip archive compressing standard input to standard output using cli tools? 如何安排 Python 脚本在每天的特定时间运行,并使其成为 AWS Elastic Beanstalk 应用程序 zip 文件的一部分? - How can I schedule a Python script to run at a particular time every day, and make it a part of AWS Elastic Beanstalk application zip file? Python S3 下载 zip 文件 - Python S3 download zip file AWS Python Lambda 无法在 zip 上构建的文件中导入模块 CodeBuild - AWS Python Lambda Unable to Import Module In zip File constructed on CodeBuild Boto3 没有将 zip 文件上传到 S3 python - Boto3 not uploading zip file to S3 python 从 ACR 拉取时,ImagePullBackOff 出现“rpc 错误:代码 = 未知描述 = 无法从 AKS 拉取和解压缩图像” - ImagePullBackOff with "rpc error: code = Unknown desc = failed to pull and unpack image" from AKS when pulling from ACR 尝试在 EKS 上运行 jitsi/web 镜像,但面临“无法拉取和解压镜像”的问题 - Trying to run jitsi/web image on EKS but facing the "failed to pull and unpack image" issue 如何从 S3 中的 zip 存档中提取文件 - How to extract files from a zip archive in S3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM