升级python(2.7-3.6.2)
#no modul _ssl # 编译的时候 –with-ssl
# 下载依赖包
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel -y
# 下载并安装python3.6.2
mkdir ~/sources cd ~/sources wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz tar xf Python-3.6.2.tgz cd Python-3.6.2 ./configure --prefix=/usr/local/python3.6.2 --with-ssl --with-universal-archs=all make && make install ln -s /usr/local/python3.6.2/ /usr/local/python echo 'PATH=/usr/local/python/bin:$PATH' >> /etc/profile export PATH=/usr/local/python/bin:$PATH
#如果上定时任务,或者编写脚本想使用python3的命令,那么使用全路径
/usr/local/python/bin/python3 test.py
测试
[root@test ~]# vim test.py [root@test ~]# cat test.py #!/usr/local/python/bin/python3 print('hello world') [root@test ~]# python3 test.py hello world [root@test ~]# chmod +x test.py [root@test ~]# ./test.py hello world