- 安装python3之前最好不要删除python2,因为yum是依赖于python2的
- 安装系统环境
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install gcc
- 下载Python-3.6.包
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
- 解压,并重命名为python3
tar -zxvf Python-3.6.5.tgz
mv Python-3.6.5 python3
cd python3
./configure --prefix=/usr/local/python3
make
make install
- 配置软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
- 查看
python3 -V
pip3 -V
-
卸载python
卸载的时候python后什么都不跟,会将python2和python3全部删除rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps #卸载python3 whereis python3 |xargs rm -frv #删除所有残余文件 whereis python3 #查看现有安装的python