Linux上Python的安装升级和回退

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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值