Centos6.7 上安装python2.7.11和pip

Centos6.7 上安装python2.7.11pip

 

yum groupinstall "Development tools" -y

 

yum install zlib-devel zlib bzip2-devel openssl-devel ncurses-devel sqlite-devel -y

yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y

安装python2.7.11

下载

wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz

tar vxf Python-2.7.11.tgz

cd Python-2.7.11

./configure --prefix=/data/python

 make && make install

/etc/profile最后加上:

PATH=/data/python/bin:$PATH

export PATH

执行source /etc/profile

检查

[root@VM_97_239_centos bin]# python

Python 2.7.11 (default, Feb 16 2017, 10:47:43)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>

python2.7.11安装成功

解决修改完系统默认python版本后yum不可用的问题

#修改yum文件

vi /usr/bin/yum

将头部

#!/usr/bin/python

改成

#!/usr/bin/python2.6

Done

 

Error:交互模式下方向键报错

 

解决办法:

yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y

重新编译PYTHON

perface!

 

安装pip

pippython安装工具,很多python的常用工具,都可以通过pip进行安装

安装pip,首先要安装setuptools

cd /data/paul/

tar zxf setuptools-28.6.0.tar.gz

cd setuptools-28.6.0

python setup.py  install

tar zxf pip-9.0.1.tar.gz

cd pip-9.0.1

python setup.py install

检查

pip

pip install psutil

 

Done!

注:安装setuptools曾碰到如下报错:

 

 

解决办法:

yum install zlib-devel zlib -y

重新编译安装python

问题Done!

posted @ 2017-03-14 16:56  静渊居士  阅读(1007)  评论(0编辑  收藏  举报