1、下载源码包
前往官网:https://www.python.org/downloads/source/
[[email protected] opt]#wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
2、安装:
安装基本GCC编译环境
yum -y install gcc gcc-c++ make automake autoconf
安装源码包
[[email protected] opt]#tar fx Python-3.5.1.tgz
[[email protected] opt]#cd Python-3.5.1
[[email protected] opt]#./configure --prefix=/usr/local/python35 #需要点时间
[[email protected] opt]#make install #需要点时间
3、配置环境变量
vi /etc/profile #全局变量文件,最底下添加下面两行
PATH=/usr/local/python3/bin:/usr/local/python3/lib:$PATH
export PATH
:wq #保存退出
source /etc/profile #生效环境变量
[[email protected]]# python3 #安装完成
Python 3.5.1 (default, May 10 2016, 10:32:08)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>