Tag Archives: zipimport.ZipImportError: can‘t decompress data; zlib not availabl

Python Via get-pip.py Install pip Error: zipimport.ZipImportError: can‘t decompress data; zlib not availabl

How to Solve error: zipimport.ZipImportError: can‘t decompress data; zlib not availablwget https://bootstrap.pypa.io/pip/2.7/get-pip.py  # python2.7
wget https://bootstrap.pypa.io/get-pip.py  # python3
error:

[[email protected] ~]$ https://bootstrap.pypa.io/get-pip.py
[[email protected] ~]$ sudo python get-pip.py

The error message “zipimport.ZipImportError: can’t decompress data; zlib not available”
It seems that the zlib library is missing and needs to be installed before execution.
Problem solved

1 [[email protected] ~]$ sudo yum install zlib

After the installation was completed, we found that it still reported an error, and a Google search revealed that we needed to install zlib-dev
So we install the zlib library again

1 [[email protected] ~]$ sudo yum install zlib*

This time the installation should be OK, but the result is disappointing, it still gives the same error.
But we have already installed the zlib library, why does it still give us an error?

We need to recompile and install python
Before recompiling, we need to modify the Modules/Setup.dist file in the installation source file to change the

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

The comment on this line is removed and becomes

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

Then compile and install it again (execute the following command in Python’s installation source directory)

1 [[email protected] ~]$ make && make install

Reinstallation completed
Execute.

1 [[email protected] ~]$ sudo python get-pip.py

Install pip successfully!