Python zlib 模块丢失
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3905615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
zlib module missing
提问by crodjer
I have compiled and installed python 2.7 on my ubuntu lucid.
But I am unable to install setuptools for python 2.7 because the data decompression module zlib is not present. This is the exact error:
我已经在我的 ubuntu lucid 上编译并安装了 python 2.7。
但是我无法为 python 2.7 安装 setuptools,因为数据解压模块 zlib 不存在。这是确切的错误:
Traceback (most recent call last):
File "setup.py", line 94, in <module>
scripts = scripts,
File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/rohan/setuptools-0.6c11/setuptools/command/install.py", line 76, in run
self.do_egg_install()
File "/home/rohan/setuptools-0.6c11/setuptools/command/install.py", line 96, in do_egg_install
self.run_command('bdist_egg')
File "/usr/local/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/home/rohan/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 236, in run
dry_run=self.dry_run, mode=self.gen_header())
File "/home/rohan/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 527, in make_zipfile
z = zipfile.ZipFile(zip_filename, mode, compression=compression)
File "/usr/local/lib/python2.7/zipfile.py", line 651, in __init__
"Compression requires the (missing) zlib module"
RuntimeError: Compression requires the (missing) zlib module
Also when i try to use setuptools 2.7 .egg, it gives this error:
此外,当我尝试使用 setuptools 2.7 .egg 时,它会出现此错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
采纳答案by Ignacio Vazquez-Abrams
You forgot to install zlib1g-devbefore building Python.
你zlib1g-dev在构建 Python 之前忘记安装了。
回答by Derek Chia
Please install this before proceeding.
请在继续之前安装它。
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev\
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev
回答by yangh
first install the companents with the following command
首先使用以下命令安装组件
yum install zlib
yum install zlib-devel
then remake python
然后重新制作python
make
make install
回答by Nate
My solution to this problem is slightly different only because I was trying to install python on a remote computer which I cannot access as a root user AND has no access to the internet. Here is my slightly modified solution:
我对这个问题的解决方案略有不同,只是因为我试图在远程计算机上安装 python,我无法以 root 用户身份访问并且无法访问互联网。这是我稍微修改的解决方案:
- Extract python (ie: tar -xzf Python-3.6.4.tgz)
- Make a directory to house the local python (ie: mkdir localpy)
- Navigate into the Modules/zlib folder in the extracted python directory (ie: cd ./Python-3.6.4/Modules/zlib)
- Configure zlib locally (ie: ./configure --prefix='/usr/h/testing/localpy' )
- Make and install zlib (make install)
- Naviage back to the extracted python folder (ie: cd ../../ )
- Configure python locally and point to zlib (ie: ./configure --prefix='/usr/h/testing/localpy' --with-zlib='/usr/h/testing/localpy')
- Make python (ie: make)
- Install python (ie: make install)
- 提取python(即:tar -xzf Python-3.6.4.tgz)
- 创建一个目录来存放本地python(即:mkdir localpy)
- 导航到解压的 python 目录中的 Modules/zlib 文件夹(即:cd ./Python-3.6.4/Modules/zlib)
- 在本地配置 zlib(即: ./configure --prefix='/usr/h/testing/localpy' )
- 制作并安装 zlib (make install)
- 导航回提取的 python 文件夹(即: cd ../../ )
- 在本地配置python并指向zlib(即:./configure --prefix='/usr/h/testing/localpy' --with-zlib='/usr/h/testing/localpy')
- 制作蟒蛇(即:制作)
- 安装python(即:make install)
This may not work for everyone, but it worked for me today.
这可能不适用于所有人,但今天对我有用。

