No Module Named Zlib

no module named zlib

Sounds like you need to install the devel package for zlib, probably want to do something like

# ubuntu 12,14,16,18,20.04+
sudo apt-get install zlib1g-dev

Instead of using python-brew you might want to consider just compiling by hand, it's not very hard. Just download the source, and configure, make, make install. You'll want to at least set --prefix to somewhere, so it'll get installed where you want.

./configure --prefix=/opt/python2.7 + other options
make
make install

You can check what configuration options are available with ./configure --help and see what your system python was compiled with by doing:

python -c "import sysconfig; print sysconfig.get_config_var('CONFIG_ARGS')"

The key is to make sure you have the development packages installed for your system, so that Python will be able to build the zlib, sqlite3, etc modules. The python docs cover the build process in more detail: http://docs.python.org/using/unix.html#building-python.

Python: No Module named Zlib, Mac OS X El Capitan 10.11.6

Installing the MacOS SDK Headers as suggested by this issue solves this problem fairly cleanly.

To do so, run the following (for MacOS 10.14):

xcode-select --install
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

and then brew install python



Related Topics



Leave a reply



Submit