Here you will find the steps to install the Zlib library on your system to resolve zipimport.zipImportError: can’t decompress data; zlib not available.
I tried to install Python 3.6 from the distribution repository, but I didn’t find that version, so I decided to follow my own guide, where I have already documented the steps to install Python from the source file.
While following the steps, I was able to run a few commands, such as
make, without any errors, but when I invoked the final command,
sudo make install
It throws the error “Zipimport.ZipImportError: can’t decompress data; zlib not available.”
This issue mostly occurs when Zlib is not installed on your system. We can easily fix this issue with the required dependencies.
Therefore, we will install Zlib libraries for Ubuntu, Debian, Centos, Fedora, Red Hat, and other major Linux based system.
Table of Contents
- Terminal with
- Build essentials for Ubuntu/Debian and development group tools should be preinstall for Centos/RHEL/Fedora.
A build-essentials or development tool helps you to fulfill dependencies that are required while installing applications, which includes an application for compiling files from the source.
To test and install, pass the following command according to your respective Linux distribution. Before that, ensure to update the official repositories to fetch the latest utilities:
$ sudo apt install install build-essential // Ubuntu/Debian $ sudo dnf groupinstall "Development Tools" // Alma/Fedora/RHEL $ sudo pacman -Syu base-devel // ArchLinux/Manjaro
Install Zlib/zlib1-g dev Dependencies on your Linux System
What is Zlib?
A zlib is a library that provides the function to compress and decompress files during the program compilation.
Installing zlib1g dev is a piece of cake for Ubuntu, Debian, and RPM users; they just need to pass one line of command, and the problem is solved.
How does Zlib Work?
Data compressed using zlib is written in a gzip or zlib wrapper. Zlib is an abstraction of the DEFLATE compression algorithm of the gzip file compression tool. The Zlib wrapper encapsulates the raw DEFLATE data by adding a header and trailer.
The size of the header used in gzip is larger than the size of the zlib header.
Install Zlib on your Linux System
To install zlib on your system, open the terminal using CTRL + ALT + T or search terminal in the Activity search bar, and pass the below command as per the respective distributions.
For Ubuntu/Debian User
$ sudo apt install zlib1g-dev
For Centos/Fedora and RPM
$ sudo yum install zlib-devel
Once you have passed the above line, the corresponding package manager will install the library, and your problem should be resolved.
Verify Installation of Zlib on your System
You can verify the installation by running a command that shows you the error, or else pass the installation command to show the zlib1g-dev version in your Linux or Ubuntu syste,:
For reference, check the below command output.
That’s all to resolve zipimport.ZipImportError: can’t decompress data; zlib not available. In case you need some assistance from my end, feel free to comment below.
See you in the next article…
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.