For my own project, I want to install Python 3.6 on my Ubuntu machine, I have passed the installation command, and a specific version was not available in the ubuntu repository. After that, I have decided to follow my own guide Building Programs from Source on any Linux Distribution in a simple way to Install Python from Gzipped source tarball.
I was able to run a few commands such as configure
and make
without any error. When I pass the final command, sudo make install,
it prints the error “zipimport.ZipImportError: can’t decompress data; zlib not available.”
This issue mostly occurs when Zlib is not installed in your system. We can easily fix this issue with the required dependencies. Therefore we will Install Zlib libraries for Ubuntu, Debian, Centos, Fedora, Redhat, and other major Linux Distributions.
Prerequisites
- Terminal with sudo privileges
- 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 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 Missing zlib1-g dev dependencies
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 or Debian and RPM user, they just need to pass one line of command, and the problem is solved.
How zlib works?
Data compressed using zlib are written in gzip or zlib wrapper. zlib is an abstraction of DEFLATE compression algorithm of gzip file compression tool. 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.
Installation
To install zlib in your system, open the terminal using CTRL + ALT + T
or search terminal in the Activity search bar and pass the below command as per 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 will be resolved.
Verify the installation
You can verify the installation by running a command which shows you the error or else pass the installation command to show zlib1g-dev version in Linux or ubuntu:
For reference check the below command output.
Zlib dependencies version check
Wrap-up
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 down.
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.