问题如题所示,它发生在我的以下环境中:
Python:编译安装的【2.6.8】
Linux:RHEL 6.5
ARCH:x86-64

具体报错如下:

[root@linux pip]# python get-pip.py                       
Traceback (most recent call last):
  File "get-pip.py", line 21492, in 
    main()
  File "get-pip.py", line 197, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
[root@linux pip]# 

解法:
安装缺少的软件包:【zlib*】

[root@linux pip]# yum install -y zlib*
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Package zlib-1.2.3-29.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.3-29.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================
 Package                                      Arch                                     Version                                           Repository                             Size
=====================================================================================================================================================================================
Installing:
 zlib-devel                                   x86_64                                   1.2.3-29.el6                                      iso                                    44 k

Transaction Summary
=====================================================================================================================================================================================
Install       1 Package(s)

Total download size: 44 k
Installed size: 115 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : zlib-devel-1.2.3-29.el6.x86_64                                                                                                                                    1/1 
  Verifying  : zlib-devel-1.2.3-29.el6.x86_64                                                                                                                                    1/1 

Installed:
  zlib-devel.x86_64 0:1.2.3-29.el6                                                                                                                                                   

Complete!
[root@linux pip]# 
[root@linux pip]# yum install -y zlib.i686 zlib-devel.i686
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package zlib.i686 0:1.2.3-29.el6 will be installed
--> Processing Dependency: libc.so.6(GLIBC_2.4) for package: zlib-1.2.3-29.el6.i686
---> Package zlib-devel.i686 0:1.2.3-29.el6 will be installed
--> Running transaction check
---> Package glibc.i686 0:2.12-1.132.el6 will be installed
--> Processing Dependency: libfreebl3.so(NSSRAWHASH_3.12.3) for package: glibc-2.12-1.132.el6.i686
--> Processing Dependency: libfreebl3.so for package: glibc-2.12-1.132.el6.i686
--> Running transaction check
---> Package nss-softokn-freebl.i686 0:3.14.3-9.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================
 Package                                            Arch                                 Version                                           Repository                           Size
=====================================================================================================================================================================================
Installing:
 zlib                                               i686                                 1.2.3-29.el6                                      iso                                  73 k
 zlib-devel                                         i686                                 1.2.3-29.el6                                      iso                                  44 k
Installing for dependencies:
 glibc                                              i686                                 2.12-1.132.el6                                    iso                                 4.3 M
 nss-softokn-freebl                                 i686                                 3.14.3-9.el6                                      iso                                 147 k

Transaction Summary
=====================================================================================================================================================================================
Install       4 Package(s)

Total download size: 4.6 M
Installed size: 14 M
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                 70 MB/s | 4.6 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : nss-softokn-freebl-3.14.3-9.el6.i686                                                                                                                              1/4 
  Installing : glibc-2.12-1.132.el6.i686                                                                                                                                         2/4 
  Installing : zlib-1.2.3-29.el6.i686                                                                                                                                            3/4 
  Installing : zlib-devel-1.2.3-29.el6.i686                                                                                                                                      4/4 
  Verifying  : glibc-2.12-1.132.el6.i686                                                                                                                                         1/4 
  Verifying  : nss-softokn-freebl-3.14.3-9.el6.i686                                                                                                                              2/4 
  Verifying  : zlib-1.2.3-29.el6.i686                                                                                                                                            3/4 
  Verifying  : zlib-devel-1.2.3-29.el6.i686                                                                                                                                      4/4 

Installed:
  zlib.i686 0:1.2.3-29.el6                                                               zlib-devel.i686 0:1.2.3-29.el6                                                              

Dependency Installed:
  glibc.i686 0:2.12-1.132.el6                                                         nss-softokn-freebl.i686 0:3.14.3-9.el6                                                        

Complete!
[root@linux pip]# 

缺少的【zlib*】RPM包安装完成后:

[root@linux pip]# yum list | grep zlib
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
zlib.i686                              1.2.3-29.el6                       @iso  
zlib.x86_64                            1.2.3-29.el6                       @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5
zlib-devel.i686                        1.2.3-29.el6                       @iso  
zlib-devel.x86_64                      1.2.3-29.el6                       @iso  
jzlib.x86_64                           1.0.7-7.5.el6                      iso   
[root@linux pip]# 

Python 2.6.8,源码包:
修改【Modules/Setup】

先备份:

[root@linux Python-2.6.8]# pwd
/software/python/Python-2.6.8
[root@linux Python-2.6.8]# 
[root@linux Python-2.6.8]# ls -ltr | grep Modules
drwxrwxr-x  8 1000 1000    4096 May 12 04:43 Modules
[root@linux Python-2.6.8]# 
[root@linux Python-2.6.8]# cd Modules/
[root@linux Modules]# 
[root@linux Modules]# ls -ltr | wc -l
151
[root@linux Modules]# 
[root@linux Modules]# ls -ltr | grep setup
-rwxr-xr-x 1 1000 1000    7431 Apr 10  2012 makesetup
[root@linux Modules]# 
[root@linux Modules]# ls -ltr | grep Setup
-rw-r--r-- 1 1000 1000   18265 Apr 10  2012 Setup.dist
-rw-r--r-- 1 1000 1000     406 Apr 10  2012 Setup.config.in
-rw-r--r-- 1 root root     368 May 12 04:42 Setup.config
-rw-r--r-- 1 root root      41 May 12 04:42 Setup.local
-rw-r--r-- 1 root root   18265 May 12 04:42 Setup
[root@linux Modules]# 
[root@linux Modules]# cp Setup Setup_old_20190513_1627
[root@linux Modules]# 

修改:

[root@linux Modules]# cat Setup | grep -A 5 "zlib module." 
# Andrew Kuchling's zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
#zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

[root@linux Modules]# 

和上面备份的原文件对比:

[root@linux Modules]# diff Setup Setup_old_20190513_1627 
464d463
< zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
[root@linux Modules]# 

Python:重新编译安装

make:

[root@linux Python-2.6.8]# pwd
/software/python/Python-2.6.8
[root@linux Python-2.6.8]# 
[root@linux Python-2.6.8]# ls -ltr
total 16380
drwxrwxr-x 23 1000 1000    4096 Apr 10  2012 Demo
-rw-r--r--  1 1000 1000   14351 Apr 10  2012 LICENSE
drwxr-xr-x  2 1000 1000    4096 Apr 10  2012 Include
drwxrwxr-x  2 1000 1000    4096 Apr 10  2012 Grammar
-rw-r--r--  1 1000 1000   39341 Apr 10  2012 Makefile.pre.in
drwxrwxr-x 11 1000 1000    4096 Apr 10  2012 Mac
drwxrwxr-x  5 1000 1000    4096 Apr 10  2012 Misc
drwxrwxr-x 20 1000 1000    4096 Apr 10  2012 Tools
-rw-r--r--  1 1000 1000   87576 Apr 10  2012 setup.py
drwxrwxr-x  5 1000 1000    4096 Apr 10  2012 RISCOS
-rw-r--r--  1 1000 1000   55027 Apr 10  2012 README
-rw-r--r--  1 1000 1000   29620 Apr 10  2012 pyconfig.h.in
drwxrwxr-x  2 1000 1000    4096 Apr 10  2012 PCbuild
drwxrwxr-x 10 1000 1000    4096 Apr 10  2012 PC
-rwxr-xr-x  1 1000 1000    7122 Apr 10  2012 install-sh
-rw-r--r--  1 1000 1000  112213 Apr 10  2012 configure.in
-rwxr-xr-x  1 1000 1000  380641 Apr 10  2012 configure
drwxrwxr-x 17 1000 1000    4096 Apr 10  2012 Doc
-rwxr-xr-x  1 root root   35691 May 12 04:42 config.status
-rw-r--r--  1 root root   39377 May 12 04:42 Makefile.pre
-rw-r--r--  1 root root   31120 May 12 04:42 pyconfig.h
-rw-r--r--  1 root root   42526 May 12 04:42 Makefile
-rw-r--r--  1 root root  490179 May 12 04:42 config.log
drwxrwxr-x  3 1000 1000    4096 May 12 04:43 Objects
drwxrwxr-x  2 1000 1000    4096 May 12 04:43 Parser
drwxrwxr-x  2 1000 1000    4096 May 12 04:43 Python
-rw-r--r--  1 root root 9607746 May 12 04:43 libpython2.6.a
-rwxr-xr-x  1 root root 5699138 May 12 04:43 python
drwxr-xr-x  5 root root    4096 May 12 04:44 build
drwxrwxr-x 43 1000 1000   12288 May 12 04:44 Lib
drwxrwxr-x  8 1000 1000    4096 May 12 05:08 Modules
[root@linux Python-2.6.8]# 
[root@linux Python-2.6.8]# make
/bin/sh ./Modules/makesetup -c ./Modules/config.c.in \
                                -s Modules \
                                Modules/Setup.config \
                                Modules/Setup.local \
                                Modules/Setup
The Makefile was updated, you may need to re-run make.
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -o Modules/config.o Modules/config.c
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -DPYTHONPATH='":plat-linux2:lib-tk:lib-old"' \
                -DPREFIX='"/usr/local"' \
                -DEXEC_PREFIX='"/usr/local"' \
                -DVERSION='"2.6"' \
                -DVPATH='""' \
                -o Modules/getpath.o ./Modules/getpath.c
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE  -I/usr/local/include -c ./Modules/zlibmodule.c -o Modules/zlibmodule.o
gcc -pthread -c -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include   -DPy_BUILD_CORE -DSVNVERSION="\"`LC_ALL=C echo Unversioned directory`\"" -o Modules/getbuildinfo.o ./Modules/getbuildinfo.c
rm -f libpython2.6.a
ar cr libpython2.6.a Modules/getbuildinfo.o
ar cr libpython2.6.a Parser/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser.o Parser/parsetok.o Parser/bitset.o Parser/metagrammar.o Parser/firstsets.o Parser/grammar.o Parser/pgen.o Parser/myreadline.o Parser/tokenizer.o
ar cr libpython2.6.a Objects/abstract.o Objects/boolobject.o Objects/bufferobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/cellobject.o Objects/classobject.o Objects/cobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/intobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/methodobject.o Objects/moduleobject.o Objects/object.o Objects/obmalloc.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/stringobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/weakrefobject.o Objects/unicodeobject.o Objects/unicodectype.o
ar cr libpython2.6.a Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/bltinmodule.o Python/ceval.o Python/compile.o Python/codecs.o Python/errors.o Python/frozen.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getmtime.o Python/getplatform.o Python/getversion.o Python/graminit.o Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o Python/mystrtoul.o Python/mysnprintf.o Python/peephole.o Python/pyarena.o Python/pyfpe.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/random.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/formatter_unicode.o Python/formatter_string.o Python/dynload_shlib.o   Python/thread.o
ar cr libpython2.6.a Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o 
ar cr libpython2.6.a Modules/threadmodule.o  Modules/signalmodule.o  Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/zipimport.o  Modules/symtablemodule.o  Modules/zlibmodule.o  Modules/xxsubtype.o
ranlib libpython2.6.a
gcc -pthread  -Xlinker -export-dynamic -o python \
                        Modules/python.o \
                        libpython2.6.a -lpthread -ldl  -lutil -L/usr/local/lib -lz   -lm  
libpython2.6.a(posixmodule.o): In function `posix_tmpnam':
/software/python/Python-2.6.8/./Modules/posixmodule.c:7261: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.6.a(posixmodule.o): In function `posix_tempnam':
/software/python/Python-2.6.8/./Modules/posixmodule.c:7216: warning: the use of `tempnam' is dangerous, better use `mkstemp'
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers

Failed to find the necessary bits to build these modules:
_curses            _curses_panel      _hashlib        
_sqlite3           _ssl               _tkinter        
bsddb185           bz2                dl              
imageop            readline           sunaudiodev     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

running build_scripts
[root@linux Python-2.6.8]# 

make install

[root@linux Python-2.6.8]# make install

(过多的输出,...)

changing mode of /usr/local/lib/python2.6/lib-dynload/_multiprocessing.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/parser.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/operator.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/syslog.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_locale.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_codecs_kr.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_ctypes.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/future_builtins.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_codecs_hk.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/ossaudiodev.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/termios.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_bsddb.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/time.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_sha.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/array.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_md5.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/resource.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/gdbm.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_codecs_jp.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/strop.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_bytesio.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_struct.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/_codecs_iso2022.so to 755
changing mode of /usr/local/lib/python2.6/lib-dynload/ to 755
running install_scripts
changing mode of /usr/local/bin/pydoc to 755
changing mode of /usr/local/bin/smtpd.py to 755
changing mode of /usr/local/bin/idle to 755
changing mode of /usr/local/bin/2to3 to 755
running install_egg_info
Removing /usr/local/lib/python2.6/lib-dynload/Python-2.6.8-py2.6.egg-info
Writing /usr/local/lib/python2.6/lib-dynload/Python-2.6.8-py2.6.egg-info
if test -f /usr/local/bin/python -o -h /usr/local/bin/python; \
        then rm -f /usr/local/bin/python; \
        else true; \
        fi
(cd /usr/local/bin; ln python2.6 python)
rm -f /usr/local/bin/python-config
(cd /usr/local/bin; ln -s python2.6-config python-config)
/usr/bin/install -c -m 644 ./Misc/python.man \
                /usr/local/share/man/man1/python.1
[root@linux Python-2.6.8]# 

然后,再试,就没问题了。
————————————————
Done。

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒