Python3:没有 gzip 或 zlib?

2024-04-10

该模块现在有其他名称吗?我似乎找不到任何信息表明该模块已被弃用或完全删除。 (这会让我更加困惑)

有谁知道这去哪儿了?



Python 3.1.2 (r312:79147, May 20 2010, 09:09:30)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.1/gzip.py", line 9, in 
    import zlib
ImportError: No module named zlib
  

更新:我在使用 Python-3.1.2/Modules/zlib/ChangeLog 的源包中找到了这个 最后一次更改是在 2005 年,并且没有提及任何重要内容。



                ChangeLog file for zlib

Changes in 1.2.3 (18 July 2005)
- Apply security vulnerability fixes to contrib/infback9 as well
- Clean up some text files (carriage returns, trailing space)
- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
  

[解决了]http://www.1stbyte.com/2005/06/26/configure-and-compile-python-with-zlib/ http://www.1stbyte.com/2005/06/26/configure-and-compile-python-with-zlib/


(通过将 URL 编辑到问题中来回答。转换为社区 wiki 答案。请参阅没有答案的问题,但问题已在评论中解决(或在聊天中扩展) https://meta.stackoverflow.com/questions/251597/question-with-no-answers-but-issue-solved-in-the-comments )

OP 写道:

[解决了]http://www.1stbyte.com/2005/06/26/configure-and-compile-python-with-zlib/ http://www.1stbyte.com/2005/06/26/configure-and-compile-python-with-zlib/

SO不赞成仅使用 URL 答案,并且在该网站上转录 GregTheGeek 的博客是不合适的。然而,总而言之,必要的步骤是:

  1. 安装适当的Zlib-dev包裹。例如在 Ubuntu 上它被称为zlib1g-dev。这将提供zlib.h包含文件。
  2. 编译 python 源代码后,运行配置脚本:./configure –with-zlib=/usr/include
  3. Now make and make install应该管用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Python3:没有 gzip 或 zlib? 的相关文章

随机推荐