Linux——安装Python

安装准备:Python-3.5.0.tar.xz

官网下载的Python最新版本

[wudk@wudk usr]$ python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:11:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Linux系统已经自带有2.6版本的Python

这里新装一个3.5的

下载的源码包解压到安装目录

tar xvf Python-3.5.0.tar.xz

./configure

make && makeinstall

就OK了

装完之后,发现python 依旧是2.6

[wudk@wudk usr]$ python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:11:10) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

python3.5可以看见新版本已经装好,老版本还存在

root@wudk usr]# python3.5
Python 3.5.0 (default, Oct 15 2015, 16:58:07) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

找到老版本可以把老板卸载掉

[wudk@wudk usr]$ rpm -q python
python-2.6.6-51.el6.i686
[root@wudk usr]# rpm -e --nodeps python-2.6.6-51.el6.i686
[root@wudk usr]# python
bash: python: command not found


这里看看helloworld

[wudk@wudk python3.5]$ vi helloworld.py 
print "hello world !"

发现报错了

[wudk@wudk python3.5]$ python3.5 helloworld.py 
  File "helloworld.py", line 1
    print "hello world !"
                        ^
SyntaxError: Missing parentheses in call to 'print'

百度一下,原来3以后print都需要带上括号print (hello world!),修改完后输出helloworld

[wudk@wudk python3.5]$ python3.5 helloworld.py 
hello world!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值