赞
踩
1、下载 https://www.python.org/ftp/python/2.7.6/
2、安装,在/usr/local目录下创建python2.7目录,将Python安装到该目录下
#创建文件夹
mkdir /usr/local/python2.7
#解压
tar xvf Python-2.7.6.tgz
cd python-2.7.6
#安装
./configure --prefix=/usr/local/python2.7
make
make install
3、将/usr/bin目录下的原来的Python的软连接重新更名
mv /usr/bin/python /usr/bin/python2.6.6
#改完后在访问python就会出现 -bash: /usr/bin/python: 没有那个文件或目录
4、将新版本大的python的软连接增加到/usr/bin目录下
ln -s /usr/local/python2.7/bin/python2.7 /usr/bin/python
5、将版本python2.7命令加入环境变量
vim /etc/profile
将export PATH=$PATH:/usr/local/python2.7/bin这句加到文件最下面
source /etc/profile
6、
python -V
#python-2.7.6
OK!
----------------------------------------------------------------------------------------------------------------------------------
回退python版本:
1、删除软连接
[root@rhel6-146 cloudera-scm-agent]# rm /usr/local/python2.7/bin/python2.7
rm: remove regular file `/usr/local/python2.7/bin/python2.7'? Y
2、cd /usr/bin
删除python
[root@rhel6-146 bin]# ll py*
-rwxr-xr-x. 1 root root 78 Oct 13 2012 pydoc
lrwxrwxrwx 1 root root 34 Sep 18 16:58 python -> /usr/local/python2.7/bin/python2.7
lrwxrwxrwx. 1 root root 6 Sep 13 09:29 python2 -> python
-rwxr-xr-x. 2 root root 4864 Oct 13 2012 python2.6
-rwxr-xr-x. 2 root root 4864 Oct 13 2012 python2.6.6
[root@rhel6-146 bin]# rm -rf python
3、mv python2.6.6 python
[root@rhel6-146 bin]# mv python2.6.6 python
[root@rhel6-146 bin]# ll py*
-rwxr-xr-x. 1 root root 78 Oct 13 2012 pydoc
-rwxr-xr-x. 2 root root 4864 Oct 13 2012 python
lrwxrwxrwx. 1 root root 6 Sep 13 09:29 python2 -> python
-rwxr-xr-x. 2 root root 4864 Oct 13 2012 python2.6
[root@rhel6-146 bin]# python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
4、删除/etc/profile
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。