前言
centos7 安装python3.6.X
一、yum安装
1.安装源
yum -y install epel-release
rpm -ivh https://repo.ius.io/ius-release-el7.rpm
2.安装python3.6
yum -y install python36u python36u-pip
如果对小版本没有特定的要求,使用yum方式无疑是最方便的安装方式。缺点就是会安装最新的小版本,无法安装特定版本。
二、源码编译安装
1.安装编译环境
yum groupinstall 'Development Tools' -y
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel -y
yum install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel -y
yum install xz-devel zlib* gcc-c++ yum-utils -y
2.获取源码包
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
3.解压编译
tar -xvzf Python-3.6.5.tgz
cd Python-3.6.5
./configure --prefix=/usr/local/python3
make
make install
4.建立软连接
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.升级pip3
编译安装的pip3版本较低,需要手动升级
pip3 install --upgrade pip
总结
介绍了centos7安装python3.6.X的两种方式