无法在unix

时间:2016-08-04 12:34:21

标签: centos pip

我尝试使用命令python ./get-pip.py -v为python安装pip模块但是它返回了zlib不可用的错误:

[root@centos1 yum.repos.d]# python ./get-pip.py -v
Traceback (most recent call last):
  File "./get-pip.py", line 19177, in <module>
    main()
  File "./get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "./get-pip.py", line 82, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

当我尝试查询zlib时,我发现它已经存在:

[root@centos1 yum.repos.d]# rpm -qa | grep --color=auto -i 'zlib'
zlib-devel-1.2.3-7.el5
perl-Compress-Zlib-1.42-1.fc6
zlib-1.2.3-7.el5
perl-IO-Zlib-1.04-4.2.1

我尝试安装zlib-devel,但仍然遇到同样的错误:

zipimport.ZipImportError: can't decompress data; zlib not available

如何修复此问题并继续安装pip,因为我需要继续安装awscli。

2 个答案:

答案 0 :(得分:0)

python-pip在epel repo中可用,通过运行yum install python-pip -y来安装它,它也将解决所有依赖项

安装后你可以自我更新pip

pip install --upgrade pip然后您可以安装awscli,pip install awscli

答案 1 :(得分:0)

手动安装“ zlib”后,再次重新安装python。

git clone https://github.com/madler/zlib.git 
cd ${ZLIB_CLONED_DIR}
./configure --prefix=/usr/local
make
sudo make install 

再次从源代码重建Python

cd ${PYTHON_SRC_CODE_DIR}  
./configure --prefix=${PYTHON_HOME_DIR}
make
sudo make install