CentOS6.8升级Python2.6到Python2.7并安装pip

时间:2022-04-23 07:57:07

貌似CentOS 6.X系统默认安装的Python都是2.6版本的?平时使用以及很多的库都是要求用到2.7版本或以上,所以新系统要做的第一件事必不可少就是升级Python啦!在这里做个简单的升级操作记录 :)

升级Python

系统默认安装的Python是2.6.6的,我们需要升级到Python2.7,用wget命令从官方下载源文件,然后解压进行编译

wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
unxz Python-2.7.10.tar.xz
tar -vxf Python-2.7.10.tar

执行完以上命令会解压得到Python-2.7.10这个文件夹,进入该目录并执行以下命令进行配置

./configure --enable-shared --enable-loadable-sqlite-extensions --with-zlib

其中--enable-loadable-sqlite-extensions是sqlite的扩展,如果需要使用的话则带上这个选项。

之后执行

vi ./Modules/Setup

找到#zlib
zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
去掉注释并保存,然后进行编译和安装

make && make install
如果上述命令编译报如下错误:
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes  -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE  -I/usr/local/include -c ./Modules/zlibmodule.c -o Modules/zlibmodule.o./Modules/zlibmodule.c:8:18: error: zlib.h: No such file or directory./Modules/zlibmodule.c:66: error: expected specifier-qualifier-list before ‘z_stream’./Modules/zlibmodule.c:73: error: expected ‘)’ before ‘zst’./Modules/zlibmodule.c: In function ‘newcompobject’:./Modules/zlibmodule.c:118: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:119: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:120: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:124: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:125: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c: In function ‘PyZlib_compress’:./Modules/zlibmodule.c:141: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:141: error: (Each undeclared identifier is reported only once./Modules/zlibmodule.c:141: error: for each function it appears in.)./Modules/zlibmodule.c:141: error: ‘input’ undeclared (first use in this function)./Modules/zlibmodule.c:141: error: ‘output’ undeclared (first use in this function)./Modules/zlibmodule.c:141: warning: left-hand operand of comma expression has no effect./Modules/zlibmodule.c:142: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)./Modules/zlibmodule.c:143: error: ‘z_stream’ undeclared (first use in this function)./Modules/zlibmodule.c:143: error: expected ‘;’ before ‘zst’./Modules/zlibmodule.c:149: error: ‘zst’ undeclared (first use in this function)./Modules/zlibmodule.c:151: error: expected expression before ‘)’ token./Modules/zlibmodule.c:161: error: ‘alloc_func’ undeclared (first use in this function)./Modules/zlibmodule.c:162: error: ‘free_func’ undeclared (first use in this function)./Modules/zlibmodule.c:162: error: expected ‘;’ before ‘Z_NULL’./Modules/zlibmodule.c:163: error: expected expression before ‘)’ token./Modules/zlibmodule.c:164: error: expected expression before ‘)’ token./Modules/zlibmodule.c:166: warning: implicit declaration of function ‘deflateInit’./Modules/zlibmodule.c:169: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:171: error: ‘Z_MEM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:175: error: ‘Z_STREAM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:180: warning: implicit declaration of function ‘deflateEnd’./Modules/zlibmodule.c:181: warning: implicit declaration of function ‘zlib_error’./Modules/zlibmodule.c:186: warning: implicit declaration of function ‘deflate’./Modules/zlibmodule.c:186: error: ‘Z_FINISH’ undeclared (first use in this function)./Modules/zlibmodule.c:189: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c: In function ‘PyZlib_decompress’:./Modules/zlibmodule.c:218: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:218: error: ‘input’ undeclared (first use in this function)./Modules/zlibmodule.c:220: error: ‘MAX_WBITS’ undeclared (first use in this function)./Modules/zlibmodule.c:222: error: ‘z_stream’ undeclared (first use in this function)./Modules/zlibmodule.c:222: error: expected ‘;’ before ‘zst’./Modules/zlibmodule.c:231: error: ‘zst’ undeclared (first use in this function)./Modules/zlibmodule.c:237: error: ‘alloc_func’ undeclared (first use in this function)./Modules/zlibmodule.c:238: error: ‘free_func’ undeclared (first use in this function)./Modules/zlibmodule.c:238: error: expected ‘;’ before ‘Z_NULL’./Modules/zlibmodule.c:239: error: expected expression before ‘)’ token./Modules/zlibmodule.c:240: error: expected expression before ‘)’ token./Modules/zlibmodule.c:241: warning: implicit declaration of function ‘inflateInit2’./Modules/zlibmodule.c:244: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:246: error: ‘Z_MEM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:251: warning: implicit declaration of function ‘inflateEnd’./Modules/zlibmodule.c:258: warning: implicit declaration of function ‘inflate’./Modules/zlibmodule.c:258: error: ‘Z_FINISH’ undeclared (first use in this function)./Modules/zlibmodule.c:262: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c:264: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c: In function ‘PyZlib_compressobj’:./Modules/zlibmodule.c:312: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)./Modules/zlibmodule.c:313: error: ‘MAX_WBITS’ undeclared (first use in this function)./Modules/zlibmodule.c:313: error: ‘MAX_MEM_LEVEL’ undeclared (first use in this function)./Modules/zlibmodule.c:322: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:322: error: ‘alloc_func’ undeclared (first use in this function)./Modules/zlibmodule.c:323: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:323: error: ‘free_func’ undeclared (first use in this function)./Modules/zlibmodule.c:323: error: expected ‘;’ before ‘Z_NULL’./Modules/zlibmodule.c:324: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:325: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:326: warning: implicit declaration of function ‘deflateInit2’./Modules/zlibmodule.c:326: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:328: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:329: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:331: error: ‘Z_MEM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:336: error: ‘Z_STREAM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:341: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘PyZlib_decompressobj’:./Modules/zlibmodule.c:350: error: ‘MAX_WBITS’ undeclared (first use in this function)./Modules/zlibmodule.c:358: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:358: error: ‘alloc_func’ undeclared (first use in this function)./Modules/zlibmodule.c:359: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:359: error: ‘free_func’ undeclared (first use in this function)./Modules/zlibmodule.c:359: error: expected ‘;’ before ‘Z_NULL’./Modules/zlibmodule.c:360: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:361: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:362: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:364: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:365: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:367: error: ‘Z_STREAM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:371: error: ‘Z_MEM_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:377: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘Comp_dealloc’:./Modules/zlibmodule.c:386: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:387: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:388: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:388: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:388: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:388: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:389: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:389: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:389: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:389: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c: In function ‘Decomp_dealloc’:./Modules/zlibmodule.c:396: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:397: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:398: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:398: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:398: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:398: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:399: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:399: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:399: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:399: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c: In function ‘PyZlib_objcompress’:./Modules/zlibmodule.c:417: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:417: error: ‘input’ undeclared (first use in this function)./Modules/zlibmodule.c:428: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:429: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:430: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:431: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:432: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:435: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:435: error: ‘Z_NO_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:440: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:440: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:443: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:445: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:449: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:457: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:458: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:463: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘save_unconsumed_input’:./Modules/zlibmodule.c:475: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c:478: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:479: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:482: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:486: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:491: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:493: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:493: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:494: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:494: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:494: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:495: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:496: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:499: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:499: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:504: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:504: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:507: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:507: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:507: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:508: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c: In function ‘PyZlib_objdecompress’:./Modules/zlibmodule.c:530: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:530: error: ‘input’ undeclared (first use in this function)./Modules/zlibmodule.c:550: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:551: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:552: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:553: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:554: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:557: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:557: error: ‘Z_SYNC_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:563: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:563: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:578: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:580: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:583: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:596: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c:596: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:601: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:607: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘PyZlib_flush’:./Modules/zlibmodule.c:628: error: ‘Z_FINISH’ undeclared (first use in this function)./Modules/zlibmodule.c:636: error: ‘Z_NO_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:645: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:646: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:647: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:648: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:651: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:656: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:656: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:659: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:661: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:665: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:672: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c:673: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:675: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:681: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:687: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:688: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:694: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘PyZlib_unflush’:./Modules/zlibmodule.c:832: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:833: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:833: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:834: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:834: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:834: error: expected expression before ‘)’ token./Modules/zlibmodule.c:834: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:835: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:836: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:836: error: expected expression before ‘)’ token./Modules/zlibmodule.c:839: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:839: error: ‘Z_FINISH’ undeclared (first use in this function)./Modules/zlibmodule.c:844: error: ‘Z_OK’ undeclared (first use in this function)./Modules/zlibmodule.c:844: error: ‘Z_BUF_ERROR’ undeclared (first use in this function)./Modules/zlibmodule.c:844: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:847: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:847: error: expected expression before ‘)’ token./Modules/zlibmodule.c:848: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:852: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:865: error: ‘Z_STREAM_END’ undeclared (first use in this function)./Modules/zlibmodule.c:866: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:867: error: ‘compobject’ has no member named ‘is_initialised’./Modules/zlibmodule.c:869: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c:876: error: ‘compobject’ has no member named ‘zst’./Modules/zlibmodule.c: In function ‘Decomp_getattr’:./Modules/zlibmodule.c:928: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:929: error: ‘compobject’ has no member named ‘unused_data’./Modules/zlibmodule.c:931: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c:932: error: ‘compobject’ has no member named ‘unconsumed_tail’./Modules/zlibmodule.c: In function ‘PyZlib_adler32’:./Modules/zlibmodule.c:951: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:951: error: ‘buf’ undeclared (first use in this function)./Modules/zlibmodule.c:960: warning: implicit declaration of function ‘adler32’./Modules/zlibmodule.c: In function ‘PyZlib_crc32’:./Modules/zlibmodule.c:974: error: ‘Byte’ undeclared (first use in this function)./Modules/zlibmodule.c:974: error: ‘buf’ undeclared (first use in this function)./Modules/zlibmodule.c:983: warning: implicit declaration of function ‘crc32’./Modules/zlibmodule.c: In function ‘initzlib’:./Modules/zlibmodule.c:1069: error: ‘MAX_WBITS’ undeclared (first use in this function)./Modules/zlibmodule.c:1071: error: ‘MAX_MEM_LEVEL’ undeclared (first use in this function)./Modules/zlibmodule.c:1072: error: ‘Z_BEST_SPEED’ undeclared (first use in this function)./Modules/zlibmodule.c:1073: error: ‘Z_BEST_COMPRESSION’ undeclared (first use in this function)./Modules/zlibmodule.c:1074: error: ‘Z_DEFAULT_COMPRESSION’ undeclared (first use in this function)./Modules/zlibmodule.c:1075: error: ‘Z_FILTERED’ undeclared (first use in this function)./Modules/zlibmodule.c:1076: error: ‘Z_HUFFMAN_ONLY’ undeclared (first use in this function)./Modules/zlibmodule.c:1077: error: ‘Z_DEFAULT_STRATEGY’ undeclared (first use in this function)./Modules/zlibmodule.c:1079: error: ‘Z_FINISH’ undeclared (first use in this function)./Modules/zlibmodule.c:1080: error: ‘Z_NO_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:1081: error: ‘Z_SYNC_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:1082: error: ‘Z_FULL_FLUSH’ undeclared (first use in this function)./Modules/zlibmodule.c:1084: error: ‘ZLIB_VERSION’ undeclared (first use in this function)make: *** [Modules/zlibmodule.o] Error 1
字面上的意思是,没有安装zlib。但实际上是有安装的:
[root@localhost ~]# rpm -qa|grep zlib
zlib-1.2.3-29.el6.x86_64

尝试重新configure,并显式指定zlib的路径:
./configure --enable-memcache --with-php-config=/usr/local/php54/bin/php-config --with-zlib-dir=/lib64/
又提示找不到zlib的相关文件:
configure: error: Can't find ZLIB headers under "/lib64/

后来发现,安装zlib-devel可解决此问题:yum install zlib-devel -y

 

安装好Python2.7之后我们需要先把Python2.6备份起来,然后再对yum的配置进行修改,如果不进行这一步操作的话,执行yum命令将会提示你Python的版本不对。

执行以下命令,对Python2.6进行备份,然后为Python2.7创建软链接

mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python

然后编辑/usr/bin/yum,将第一行的#!/usr/bin/python修改成#!/usr/bin/python2.6.6
现在执行yum命令已经不会出现之前的错误信息了。

我们执行python
-V
查看版本信息,如果出现错误

error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

编辑配置文件

vi /etc/ld.so.conf

添加新的一行内容/usr/local/lib,保存退出,然后

/sbin/ldconfig  
/sbin/ldconfig -v

安装pip

下载最新版的pip,然后安装

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

查找pip的位置

whereis pip

找到pip2.7的路径,为其创建软链作为系统默认的启动版本

ln -s /usr/local/bin/pip2.7 /usr/bin/pip

pip安装完毕,现在可以用它下载安装各种包了 :)