1、使用脚本安装Python3
Python2一般Llinux系统中默认安装的版本,我们需要使用如下命令安装一下Python3:
1)下载脚本
wget http://file.aionlife.xyz/source/download?id=5bac8dacdc72d91ff8d539fd -O installpy3.sh
2)执行安装脚本
bash installpy3.sh
3)测试是否安装成功
[root@kvm4 ~]# python3Python 3.6.4 (default, Jul 13 2018, 19:40:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linuxType "help", "copyright", "credits" or "license" for more information.>>> [root@kvm4 ~]# pip3 -V
4)安装其它版本
yum install -y wget epel-release xz gcc zlib zlib-devel openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-develif [[ ! -s /usr/bin/python3 ]]; then wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tar.xz -O Python-3.7.9.tar.xz tar -Jxvf Python-3.7.9.tar.xz cd Python-3.7.9 ./configure --prefix=/usr/python3.7 make&&make install ln -s /usr/python3.7/bin/python3 /usr/bin/python3 mkdir ~/.pip echo -e "[global]\nindex-url = http://mirrors.aliyun.com/pypi/simple/\n[install]\ntrusted-host = mirrors.aliyun.com" > ~/.pip/pip.conf ln -s /usr/python3.7/bin/pip3 /usr/bin/pip3fi
Python3源码地址:https://www.python.org/downloads/source/
注意:需要安装其它版本,修改Python 3源码文件下载地址,在修改对应的文件名和目录名中的版本就可以了。
5) 测试是否安装
python -V
python3 -V
显示相应的版本信息即安装成功