GZIP python3 AttributeError:“模块"对象没有属性“压缩" [英] GZIP python3 AttributeError: 'module' object has no attribute 'compress'

查看:64
本文介绍了GZIP python3 AttributeError:“模块"对象没有属性“压缩"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

pipe.setnx(prefix+item[0], gzip.compress(bytes(item[1], 'utf-8')))

我正在尝试使用EC2实例上的gzip python lib压缩文件.我认为gzip是标准库的一部分.但是,出现以下错误

I'm trying to compress a file using the gzip python lib on an EC2 instance. I assume that gzip is part of the standard library. However, I get the following error

AttributeError: 'module' object has no attribute 'compress'

推荐答案

我发现其他人添加了一个名为gzip的库.因此,它默认为该库,而不是标准库.我最终改为使用zlib.

I figured out that someone else had added a library called gzip. So, it was defaulting to that one and the not standard library. I ended up using zlib instead.

这篇关于GZIP python3 AttributeError:“模块"对象没有属性“压缩"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆