1、安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2、下载安装包(可以Windows下载https://www.python.org/downloads/也可以用wget
wget -c https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
下载tgz 包
3、新建一个Python的安装目录,mkdir /root/pyrhon36
4、进入tgz包的路径解压:tar -vxzf Python-3.6.1.tar.gz
5、解压完成,cd Python-3.6.1
6、指定Python的安装路径 ./configure --prefix=/root/python36
7、make
8、make install
9、因为Linux默认安装Python2,需要修改软链接:ln -s /root/python36/bin/python3.6 /usr/bin/python
10、修改pip的软链接:ln -s /root/python36/bin/pip3 /usr/bin/pip
11、配置环境变量 vim ~~/.bash_profile 编辑
PATH
=
$PATH:$HOME
/
bin
:
/
root
/
python36
/
bin
export PATH
ps:修改软链接以后yum 使用报错,需要修改报错文件使用Python3