building Python from source with zlib support
Question: When building Python 3.2.3 from source on Ubuntu 12.04, the zlib module is not
available.

I downloaded the official source distribution from python.org, and attempted
to build and install it with the following commands.

    
    
    tar xfa Python3.2.3.tar.bz2
    cd Python-3.2.3
    ./configure --prefix=/opt/python3.2
    make
    sudo make install
    

The make command output includes the following.

    
    
    Python build finished, but the necessary bits to build these modules were not found:
    _curses            _curses_panel      _dbm            
    _gdbm              _sqlite3           _ssl            
    _tkinter           bz2                readline        
    zlib                                            
    

After running `make install` and starting the interpreter, the `zlib` module
cannot be imported.

I confirmed that the `zlib1g-dev` package is installed on my system.

I also found [this similar
question](http://stackoverflow.com/questions/6169522/no-module-named-zlib),
which suggests adding the `--with-zlib` flag to the `./configure` command.
However, that returns an error that it is an unrecognized option and has no
effect.


Answer: I had a similar problem on CentOS 6.3 and python 3.2.3

I solved it by:

Edit `/Modules/Setup` and uncomment the line:

    
    
    zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
    

change to directory /Modules/zlib:

    
    
    ./configure
    make
    sudo make install
    

then compiled my python3.2 source.

and was then able to test import zlib and it all worked fine :)

