1、安装python3之前需要先安装一些依赖
yum -y install zlib* bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel gcc libffi-devel gcc make automake autoconf libtool libffi-devel
2、下载python3.7安装包,请参见https://www.python.org/downloads/source/
3、解压文件
tar -zxvf 下载的文件名
[root@localhost opt]# tar -zxvf Python-3.7.6.tgz
4、进入Python文件夹目录
cd 解压文件夹名
[root@localhost opt]# cd Python-3.7.6
5、初始配置
[root@localhost Python-3.7.6]#./configure --prefix=/usr/local/python3
6、安装
[root@localhost Python-3.7.6]# make && make install
7、配置软连接
ln -s /usr/local/python3/bin/python(你安装的版本号) /usr/bin/python3
谨慎操作:ln -s /usr/local/python3/bin/python(你安装的版本号) /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@localhost bin]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
[root@localhost bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
8、验证成功
[root@localhost ~]# python3 -V
[root@localhost ~]# pip3 -V
版权声明:本文为weixin_38850930原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。