安装准备: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!