Tuesday, February 6, 2018

can't decompress data; zlib not available

When I tried to run this python but encountered the following error.
# python get-pip.py           
Traceback (most recent call last):
  File "get-pip.py", line 20061, in
    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

ENV: Python 3.5.2 + CentOS 7.4

Resolution: 


1. Install Zlib module
# yum -y install zlib*
# rpm -qa |grep -i zlib
zlib-1.2.7-17.el7.i686
zlib-static-1.2.7-17.el7.x86_64
zlib-1.2.7-17.el7.x86_64
perl-Compress-Raw-Zlib-2.061-4.el7.x86_64
zlib-devel-1.2.7-17.el7.x86_64

2. Modify the source installation file
vi /Modules/Setup

# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

3. Finally, you need to compile the python again.
# make & make install

4. Try to run the python CMD again.

No comments:

change yum source to SJTU

edit this file, /etc/yum.repos.d/CentOS-Base.repo # CentOS-Base.repo # # The mirror system uses the connecting IP address of the client ...