98

On RHEL 6.6, I installed Python 3.5.1 from source. I am trying to install pip3 via get-pip.py, but I get

Traceback (most recent call last):
  File "get-pip.py", line 19177, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

It works for the Python 2.6.6 installed. I have looked online for answers, but I cannot seem to find any that works for me.

edit: yum search zlib

jzlib.i686 : JZlib re-implementation of zlib in pure Java
perl-Compress-Raw-Zlib.i686 : Low-Level Interface to the zlib compression library
perl-Compress-Zlib.i686 : A module providing Perl interfaces to the zlib compression library
perl-IO-Zlib.i686 : Perl IO:: style interface to Compress::Zlib
zlib.i686 : The zlib compression and decompression library
zlib-debuginfo.i686 : Debug information for package zlib
zlib-devel.i686 : Header files and libraries for Zlib development
perl-IO-Compress-Zlib.i686 : Perl interface to allow reading and writing of gzip and zip data

  Name and summary matches only, use "search all" for everything.
8
  • can you show the exact command.
    – AReddy
    Jun 24 '16 at 3:42
  • can you search for zlib package.
    – AReddy
    Jun 24 '16 at 3:54
  • I run python3 get-pip.py to show the error message above, but it works for python get-pip.py. Yes, I can run yum search zlib.
    – Flair
    Jun 27 '16 at 17:36
  • Based on your comments, you do have zlib installed, but perhaps there's a python-zlib wrapper you need? Jun 27 '16 at 19:10
  • How would I go about doing that?
    – Flair
    Jun 28 '16 at 20:29
146

Ubuntu 16.10+ and Python 3.7 dev

sudo apt-get install zlib1g-dev

Note: I only put this here because it was the top search result for the error, but this resolved my issue.

Update: also the case for ubuntu 14.04LTS and base kernel at 4.1+

2
  • 4
    Thanks! it helped me resolve the issue installing 3.7.1 on Ubuntu 18.04
    – daonb
    Dec 6 '18 at 11:29
  • 2
    Helped resolve issue for python3+ on Ubuntu 20
    – dannypaz
    Aug 17 '20 at 7:49
47

The solution is : # yum install zlib-devel



3
  • 5
    I tried that. It says Setting up Install Process rhel6_latest | 1.9 kB 00:00 Package zlib-devel-1.2.3-29.el6.i686 already installed and latest version Nothing to do, but I still get the zipimport error.
    – Flair
    Jun 27 '16 at 17:32
  • did not solve my problem Sep 28 '18 at 8:32
  • This should be the current answer. Thanks Oct 8 '19 at 18:18
8

Simply copy paste this code:

CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \
pyenv install -v 3.6.0
2
  • This doesn't seem like RHEL. Dec 2 '20 at 23:57
  • 1
    It's macOS only solution (and brew also should be installed as pre-requisite). Still - good partial solution
    – Alfishe
    Feb 25 at 21:40
3

Throwing my 2cents. I've been dealing with this issue for the past 3 hours and realized that python3.6 for me was installed was in /usr/local/bin/.

I remade the configure with --prefix==/usr/bin and pip installed.

Installing collected packages: setuptools, pip Successfully installed pip-9.0.1 setuptools-28.8.0

2

you don't have decompress tool,You should install zlib .

Updated Answer

first check if its installed

yum list python-gzipstream

If not then run the below to install

yum install python-gzipstream.noarch

I have this installed on my system

 yum list python-gzipstream
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.webwerks.com
 * epel: ftp.kddilabs.jp
 * extras: centos.webwerks.com
 * updates: mirror.nbrc.ac.in
Available Packages
python-gzipstream.noarch                                                                1.4.3-1.el6                                                                 epel
6
  • 4
    I ran yum install zlib. I get that I already have the latest version. I still get the same error.
    – Flair
    Jun 27 '16 at 17:34
  • check the updated answer
    – AReddy
    Jun 28 '16 at 3:41
  • 1
    For yum list python-gzipstream, I get Error: No matching Packages to list , and for yum install python-gzipstream.noarch, I get No package python-gzipstream.noarch available. Error: Nothing to do
    – Flair
    Jun 28 '16 at 20:28
  • can you show is us the output of yum repolist & yum search zlib.
    – AReddy
    Jun 29 '16 at 3:46
  • For repolist, repo id repo name status rhel6_latest Red Hat Enterprise Linux 6Server - i386 - latest 11,637 repolist: 11,637
    – Flair
    Jun 29 '16 at 23:04
1

The zlib module is an optional feature for python and it seems that the version of python3.5 in RHEL 6.6 does not include it. You can verify this:

python3 -c "import zlib"

So you'll either need to obtain a zlib enabled version of python (or python libraries) or rebuild python from source with the zlib feature enabled - see here for help: https://stackoverflow.com/questions/12344970/building-python-from-source-with-zlib-support

Not the answer you're looking for? Browse other questions tagged or ask your own question.