File "/usr/local/lib/python3.2/distutils/archive_util.py", line 52, in make_tarball
    tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
  File "/usr/local/lib/python3.2/tarfile.py", line 1769, in open
    stream = _Stream(name, filemode, comptype, fileobj, bufsize)
  File "/usr/local/lib/python3.2/tarfile.py", line 421, in __init__
    raise CompressionError("zlib module is not available")
tarfile.CompressionError: zlib module is not available
garrett@toshiba-laptop ~/Desktop/nester $ 

I'M getting the above error while trying to build a small module with the command "python3 setup.py sdist

nester.py

"""This is the "nester.py" module and it provides one function called
print_lol() which prints lists that may or may not include nested lists."""

def print_lol(the_list):
    """This function takes a positional argument called "the_list", which is any
    Python list (of, possibly, nested lists). Each data itemin the provided list
    is (recursibely) printed to the screen on it's own line."""
    for each_item in the_list:
        if isinstance(each_item, list):
            print_lol(each_item)
        else:
            print(each_item)


movies = ["The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91,
["Graham Chapman",
["Michael Palin", "John Cleese", "Terry Gilliam", "Eric Idle", "Terry Jones"]]]

setup.py

from distutils.core import setup

setup(
    name        = 'nester',
    version     = '1.0.0',
    py_modules  = ['nester'],
    author      = 'hfpython',
    author_email    = 'hfpython@headfirstlabs.com',
    url     = 'http://www.headfirstlabs.com',
    description = 'A simple printer of nested lists',
)

AFAIK zlib support should be built into Python.
So I think it's most likely that you just need to install the zlib libraries/.so's onto your system. Just open your package manager and search for zlib and then install the appropriate files.

Although, from seeing some of your previous posts; I know that you've been trying to build a LFS system too. So if this problem is on your LFS machine and you built Python yourself, you might want to consider installing the zlib libraries and development files before reconfiguring and rebuilding Python from source. There's probably an option to explicitly enable zlib. Otherwise when you ran ./configure on the previous build; perhaps the configure script failed to find the zlib libraries and/or headers and automatically set an option to disable zlib support.

But if it's a stock install of a pre-built distro, it's far more likely that you simply don't have the appropriate zlib libraries/.so's installed.

Either way, installing the zlib libraries (and development files in the case that a rebuild is required) should solve the problem..... I think!
Also, if you are on a 64-bit system, you might want to make sure you have the 64-bit and 32-bit versions of zlib installed!

Thanks. I'M not actually doing this on the LFS machine. That project was tough enuff on it's own.

This article has been dead for over six months. Start a new discussion instead.