[Solved]-Can't fix "zipimport.ZipImportError: can't decompress data; zlib not available" when I type in "python3.6 get-pip.py"


I also came across this problem (while creating a simple installer for pyenv). Here’s how I solved it for Mac and Linux:

Ubuntu 20.04, 18.04

You need the zlib development files, and probably zlib itself too:

sudo apt install -y zlib1g-dev zlibc

If you’re missing zlib, it’s likely that the next problem you’ll run into is with openssl, so it’s probably best to get that now as well:

sudo apt install -y libssl-dev
sudo apt install -y libssl1.1 || sudo apt install -y libssl1.0


I believe this comes with XCode CLI Tools (or at least I didn’t have to custom install it Big Sur):

xcode-select --install


For me it worked in RHEL:
$ yum install zlib-devel


Suggested solutions (installing zlib1g-dev or zlib-devel) seem to resolve the issue in most cases. Here is one edge case I’ve encountered recently: whatever you are trying to run might use zlib via symlink which might be broken.

In my case I was trying to run a build of a 3rd-party software which already had python and all necessary libs being emebedded into it. It was packaged as a tar.gz archive. Unpacking the archive on a Windows machine and then copying the contents to another linux machine destroyed all the symlinks (if you do ls -l in a folder with symlinks you would see that all of them have size 0 and do not point to anything). Copying tar.gz to the linux machine directly and unpacking it there resolved the issue.

P.S. I know it’s an edge case scenario but it took me and one more developer quite a while to figure it out so I think it’s worth mentioning here, just in case someone gets as unlucky as I got.


Its solves my issue for centos 7.6 :-
yum install zlib-deve


for centos7.x yum install zlib-devel

Leave a comment