一、下载python3的所需版本。
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
二、解压缩文件
tar -xvf Python-3.6.0.tgz
三、创建安装路径。
mkdir /usr/local/python3
cd Python-3.6.0
四、编译。
./configure --prefix=/usr/local/python3
五、安装。
1、make
2、make install
3、完毕
六、创建新版本的软连接。
1、修改旧版本
mv /usr/bin/python /usr/bin/python_bak
2、创建新的软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python
3、检查python的版本
python -V
python-3.6.0
软连接创建成功
七、pip3 路径配置。
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
#PATH=$PATH:$HOME/bin
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
八、source生效
[root@linux Python-3.6.0]# source ~/.bash_profile
安装完成!