- 下载Python安装包
cd /usr/local/src
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
- 解压
tar -zxvf Python-3.6.0.tgz
- 进入解压目录
cd Python-3.6.0
- 编译安装包
./configure --prefix=/usr/local/python
make && make install
- 添加环境变量
echo PATH='/usr/local/python/bin/:$PATH' >> /etc/profile
source /etc/profile
- 检查是否成功,执行下面代码
python3.6
Python 3.6.0 (default, Jun 1 2017, 14:01:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello word')
hello word