gpt4 book ai didi

Can't fix "zipimport.ZipImportError: can't decompress data; zlib not available" when I type in "python3.6 get-pip.py"(当我输入“python3.6 get-pip.py”时,无法修复“zipimport.zipimport错误:无法解压缩数据;zlib不可用”)

转载 作者:bug小助手 更新时间:2023-10-22 17:34:55 26 4
gpt4 key购买 nike



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

我试着安装Django。事实证明,该课程的老师说,我们将使用Python 3.6,我安装Python 3.6。现在它是我的默认版本,它在某种程度上取代了我的上一个版本;即Python 3.5。在那之前一切都很好。但当我想安装Django进行“pip3-install-Django”时,它告诉我模块已经满足了,因此安装了。



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

我在终端中运行“python3”命令。它运行Python 3.6。我尝试导入Django,然后。。。“没有名为'django'的模块”。



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

然后我意识到pip3实际上是在把我的模块安装到Python 3.5中,而不是3.6中。所以我所做的就是在Python 3.6中安装pip。



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

我下载了get-pip.py,然后用Python 3.6输入“python3.6 get-pip.py”来执行它。



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

这是当该死的“ziimport.ZipImportError:无法解压缩数据;zlib不可用”进入时。我尝试了很多事情,但没有人修复%^$!问题我真的很累。



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

我已经尝试过:python3.6-m pip-install-django,其输出为“/usr/local/bin/python3.6:No module named pip”



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

apt-install-zlib,输出为“E:无法定位包zlib”



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

apt-install zlib1g-dev,表示已经安装;但问题依然存在。


更多回答

Do you have pip3.6 available?

你有pip3.6可用吗?

No, how do I install it?

否,如何安装?

Try running "python3.6 -m ensurepip"

尝试运行“python3.6-m ensurepip”

I have already ran it. It throws the same error. "zipimport.ZipImportError: can't decompress data; zlib not available"

我已经运行过了。它会抛出同样的错误。“ziimport.zipimport错误:无法解压缩数据;zlib不可用”

I have the same problem in Fedora 32, I was able to fix it running: sudo dnf install zlib-devel.x86_64 , maybe you can find similar package with apt

我在Fedora 32中也有同样的问题,我能够在运行时修复它:sudo dnf install zlib-devel.x86_64,也许你可以用apt找到类似的包

优秀答案推荐

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

我也遇到了这个问题(在为pyenv创建一个简单的安装程序时)。以下是我为Mac和Linux解决问题的方法:


Ubuntu 20.04, 18.04


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

您需要zlib开发文件,可能还需要zlib本身:


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:

如果您缺少zlib,那么您可能会遇到的下一个问题是openssl,所以现在最好也这样做:


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):

我相信这是XCode CLI工具附带的(或者至少我不必自定义安装它Big Sur):


xcode-select --install


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

对我来说,它在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.

在大多数情况下,建议的解决方案(安装zlib1g-dev或zlib-devel)似乎可以解决这个问题。这是我最近遇到的一个边缘案例:无论你试图运行什么,都可能通过符号链接使用zlib,这可能会被破坏。


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.

在我的案例中,我试图运行一个第三方软件的构建,该软件已经嵌入了python和所有必要的库。它被打包为tar.gz档案。在Windows机器上打开档案,然后将内容复制到另一台linux机器上,会破坏所有符号链接(如果你在一个有符号链接的文件夹中执行ls-l操作,你会发现所有符号链接的大小都为0,并且没有指向任何东西)。将tar.gz直接复制到linux机器上并在那里拆包就解决了这个问题。


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

它解决了我在centos 7.6中的问题:-yum-install-zlib-deve



for centos7.x yum install zlib-devel

对于centos7.x,通过百胜安装zlib-devel


更多回答

not work for me, using docker image ubuntu:18.04, python2.7.8

不适用于我,使用docker镜像ubuntu:18.04,python2.7.8

had no luck either, I got the same error message re zlib being missing. Will return if I find a solution.

运气也不好,我收到了同样的错误消息re-zlib丢失了。如果我找到解决方案,我会回来的。

works for me too. THANK you~~

对我也有用。谢谢~~

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com