Python3: no gzip or zlib?

2019-07-04 00:20发布

问题:

is this module named something else now? I can't seem to find any info saying that this module was deprecated or dropped completely. (which would confuse me further)

Anyone know where this went?

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

UPDATE: I found this in the source bundle i used Python-3.1.2/Modules/zlib/ChangeLog The last change was in 2005 and it doesn't mention anything telling.

                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]

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

回答1:

(Answered by editing a URL into the question. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )

The OP wrote:

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

SO deprecates URL only answers, and it would be inappropriate to transcribe the blog from GregTheGeek on that site. However, in summary, the steps necessary are:

  1. Install the appropriate Zlib-dev package. For example on Ubuntu it is called zlib1g-dev. This will provide the zlib.h include file.
  2. After compiling your python sources run the configure script: ./configure –with-zlib=/usr/include
  3. Now make and make install should work.