centos安装python3
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 libffi-devel
2) 下载python3安装包
[root@python tools]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
3) 解压
[root@python tools]# tar xvzf Python-3.7.4.tgz
4) 创建文件夹把python3安装在里面
[root@python tools]# mkdir -p /usr/local/python3
[root@python tools]# cd Python-3.7.4
[root@python Python-3.7.4]# ./configure --prefix=/usr/local/python3/
[root@python Python-3.7.4]# make && make install
5) 建立软连接
[root@python Python-3.7.4]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
[root@python Python-3.7.4]# ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
6) 验证和测试
[root@python Python-3.7.4]# python3
Python 3.7.4 (default, Jul 26 2019, 04:16:54)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>