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

柔情痞子 提交于 2020-01-25 09:00:48

问题


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

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'

回答1:


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.



来源:https://stackoverflow.com/questions/51216128/gzip-python3-attributeerror-module-object-has-no-attribute-compress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!