2010-10-11 117 views
13

我已經編譯並安裝了python 2.7在我的ubuntu lucid上。
但我無法安裝python 2.7的setuptools,因爲數據解壓縮模塊zlib不存在。這是確切的錯誤: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 

還當我嘗試使用setuptools的2.7 .egg,它給出了這樣的錯誤:

Traceback (most recent call last): 
File "<string>", line 1, in <module> 
zipimport.ZipImportError: can't decompress data; zlib not available 

回答

27

你忘建設的Python之前安裝zlib1g-dev

+2

thanx ....我會在編譯之前總是做apt-get build-dep python :),我認爲它也會修復我的HTTPSHandler錯誤.. – crodjer 2010-10-11 11:30:30

+0

如果你使用的是RHEL/CentOS,那麼'zlib-devel' – 2017-04-02 02:44:03

4

請繼續安裝。

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev\ 
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev 

Pyenv - Common build problems

+4

在centOS 6.7上:'''yum安裝zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel''從[這裏](https://github.com/h2oai/h2o-2/wiki/Installing-蟒蛇-2.7上的CentOS-6.3.-跟蹤這個序列 - 這正是換CentOS的機器只) – 2016-02-16 20:41:47

2

先用以下命令安裝companents

yum install zlib 
yum install zlib-devel 

然後重拍蟒

make 
make install 
0

我的解決辦法,以這個問題稍微有點不同,只是因爲我試圖在遠程計算機上安裝python,我無法以root用戶的身份訪問它,並且無法訪問互聯網。這是我稍微修改的方案:

  1. 提取蟒蛇(即:焦油-xzf Python的3.6.4.tgz)
  2. 做一個目錄,以存放在本地的Python(即上:mkdir localpy)
  3. 導航(例如:cd ./Python-3.6.4/Modules/zlib)
  4. 在本地配置zlib(即:./configure --prefix ='/ usr/h/testing/localpy')
  5. 製作並安裝zlib(make install)
  6. Naviage回到extr (即:cd ../../)
  7. 在本地配置python並指向zlib(即:./configure --prefix ='/ usr/h/testing/localpy'--with-zlib = '在/ usr/H /測試/ localpy')
  8. 使Python(即:使)
  9. 安裝Python(即:使安裝)

這可能不適合每一個人,但它爲我工作今天。