Zipimport.zipimporterror cant decompress data zlib not available

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

macOS

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

Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

Questions : Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

2022-09-15T13:14:04+00:00 2022-09-15T13:14:04+00:00

650

I was trying to install Django. Turns out anycodings_python that course's teacher said that we will be anycodings_python working with Python 3.6 I install Python anycodings_python 3.6. Now it's my default, it somewhat anycodings_python replaced the last version I had; which is anycodings_python Python 3.5. Everything ok until that. But anycodings_python when I want to install Django doing "pip3 anycodings_python install django", it tells me that the module anycodings_python is already satisfied and therefore anycodings_python installed.

I run "python3" command into my terminal. It anycodings_python runs Python 3.6. I try to import Django, and anycodings_python boom... "No module named 'django'".

Then I realized pip3 was actually installing anycodings_python my modules into Python 3.5 and not 3.6. So anycodings_python what I do is to install pip in Python 3.6.

I download get-pip.py and proceed to execute anycodings_python it with Python 3.6 typing in "python3.6 anycodings_python get-pip.py".

Here is when the damn anycodings_python "zipimport.ZipImportError: can't decompress anycodings_python data; zlib not available" goes in. I've anycodings_python tried a ton of things and no one of them anycodings_python fixed the %^$! problem. I'm really tired.

What I have already tried: python3.6 -m pip anycodings_python install django, which output is anycodings_python "/usr/local/bin/python3.6: No module named anycodings_python pip"

apt install zlib, which output is "E: Unable anycodings_python to locate package zlib"

apt install zlib1g-dev, which says that it's anycodings_python already installed; the problem persists anycodings_python though.

Total Answers 4

27

Answers 1 : of Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

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

Ubuntu 20.04, 18.04

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

sudo apt install -y zlib1g-dev zlibc

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

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

macOS

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

xcode-select --install

0

2022-09-15T13:14:04+00:00 2022-09-15T13:14:04+00:00Answer Link

mRahman

3

Answers 2 : of Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

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

0

2022-09-15T13:14:04+00:00 2022-09-15T13:14:04+00:00Answer Link

jidam

3

Answers 3 : of Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

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

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

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

0

2022-09-15T13:14:04+00:00 2022-09-15T13:14:04+00:00Answer Link

jidam

2

Answers 4 : of Cant fix zipimport.ZipImportError: cant decompress data; zlib not available when I type in python3.6 get-pip.py

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

0

2022-09-15T13:14:04+00:00 2022-09-15T13:14:04+00:00Answer Link

jidam

Can't decompress data zlib not available python?

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.

How do I download zlib?

How to Install zlib package on Ubuntu 20.04 LTS (Focal Fossa).
Step 1: Prerequisites. a) You should have a running Ubuntu 20.04 LTS Server. ... .
Step 2: Update Your Server. ... .
Step 3: Install zlib package. ... .
Step 4: Verify Package Installation..