以centos为例python
默认python版本为:linux
python
Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
vim
升级py 咱们这边用的是较新的版本3.5centos
1、下载及安装
ide
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar -zxvf Python-3.5.2.tgz
cd Python-3.5.2
mkdir /usr/local/python3
./configure --prefix=/usr/local/python3
make && make installorm
2、重命名老python版本,把新版本软链接到系统环境中
get
mv /usr/bin/python /usr/bin/python_26
ln -s /usr/local/python3/bin/python3 /usr/bin/pythonit
3、验证
python
Python 3.5.2 (default, Dec 29 2016, 16:34:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
io
[root@station88 Python-3.5.2]# cat test.py
import os
print ('hello world')
[root@station88 Python-3.5.2]# python test.py
hello world
[root@station88 Python-3.5.2]#
form
报错处理:
使用yum报错
解决:
[root@station88 ~]# cp /usr/bin/yum /usr/bin/yum.backup_2016-12-30
vim /usr/bin/yum
#!/usr/bin/python 修改成:/usr/bin/python_2016-12-30
cat /usr/bin/yum |grep /usr/bin/pyth#!/usr/bin/python2.6