Cento7安装Python3
一.解决依赖
yum install zilb-devel python3-devel ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
二.下载python3
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
# 解压
xz -d Python-3.6.1.tar.xz
tar -xvf Python-3.6.1.tar.xz
三.安装
cd Python-3.6.1
sudo ./configure --prfix=/usr/local/python3 --enable-optimizations
# 将资源文件都解压到这里
# 编译 & 安装
sudo make & make install
四.创建软链接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
sudo ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 最后:
在终端输入python3,即可
安装py3的模块,需要用 pip3 install xxx 去安装。
python2.7正常使用,切记千万不要覆盖掉 python2.7的软链接,因为yum依赖于py2.7