centos 6.5 升级python2.7

一、安装python

1.下载链接python

https://www.python.org/downloads/

2.解压编译安装

 1. tar -xvf Python-2.7.10.tar #解压
 2. mkdir /usr/local/python2.7 #创建安装目录
 3. cd Python-2.7.10 #进入解压后的Python目录
 4. /configure --prefix=/usr/local/python2.7  #等待编译完成
 5. make && make install #等待安装
 6. mv /usr/bin/python /usr/bin/python2.6 #将原版本的python解释器换个名字
 7. ln -s /usr/local/python2.7 /usr/bin/python #创建解释器的软连接

3.配置python2.7解释器的环境变量

1. cd ~    #进入家目录
2. echo export PATH=$HOME/bin:/usr/local/python27/bin:/usr/local/bin:$PATH >> .bash_profile   #给当前用户添加解释器的环境变量
3. source .bash_profile  #更新环境变量
4. echo export PATH=$HOME/bin:/usr/local/python27/bin:/usr/local/bin:$PATH >> /etc/profile    #配置全局环境变量
5. source /etc/profile

二、安装pip

1.下载安装setuptools

https://pypi.python.org/pypi/setuptools
 tar -zxvf setuptools-26.0.0.tar.gz 
 cd setuptools-26.0.0
 python setup.py install

2.下载安装pip

https://pypi.python.org/pypi/pip
 tar -zxvf pip-8.1.2.tar.gz
 cd pip-8.1.2
 python setup.py install

你可能感兴趣的:(centos 6.5 升级python2.7)