良玉的博客 点点滴滴,积水成河_良玉的博客_页游、手游linux运维工程师之路

centos下Python安装setuptools时报RuntimeError: Compression requires the (missing) zlib module

背景: 虚拟CentOS安装Python辅助工具 setuptools报错,错误信息大概如下:

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 "/opt/Oracle/sor/install/setuptools-0.6c11/setuptools/command/install.py", line 76, in run 

self.do_egg_install() 

File "/opt/oracle/sor/install/setuptools-0.6c11/setuptools/command/install.py", line 96, in do_egg_install 

self.run_command(&apos;bdist_egg&apos;) 

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 "/opt/oracle/sor/install/setuptools-0.6c11/setuptools/command/bdist_egg.py", line 236, in run 

dry_run=self.dry_run, mode=self.gen_header()) 

File "/opt/oracle/sor/install/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 681, in __init__ 

"Compression requires the (missing) zlib module" 

RuntimeError: Compression requires the (missing) zlib module

出错原因:

提示的很清楚,缺少 zlib模块导致安装失败

解决方式:

# yum install zlib 

# yum install zlib-devel 

下载成功后,进入python2.7的目录,重新执行 

#make 

#make install 

此时先前执行的 软连接仍旧生效 

然后进入 setuptool目录, 

[root@localhost setuptools-5.2]# pythonnew setup.py install  重新安装

基本这样就可以搞定。


在ubuntu软件源里zlib和zlib-devel叫做zlib1g zlib1g.dev
        $ sudo apt-get install zlib1g
        $ sudo apt-get install zlib1g.dev
       直接输入上述命令后还是不能安装。这就要求我们先装ruby.
       在ubuntu里,zlib叫zlib1g,相应的zlib-devel叫zlib1g.dev。默认的安装源里没有zlib1g.dev。要在packages.ubuntu.com上找。
       $sudo apt-get install ruby
       然后再装zlib1g-dev就可以了
       $sudo apt-get install zlib1g-dev

标签: pythonsetuptools

作者:良玉 分类:Python 浏览:278 评论:0
留言列表
发表评论
来宾的头像