yum -y groupinstall "Development tools"
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
yum install libffi-devel -y
下载python3.8安装包
wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
解压缩
tar -zxvf Python-3.8.1.tgz
进入目录
cd Python-3.8.1
新建目录
用于安装
mkdir /usr/local/python3
配置安装路径
./configure --prefix=/usr/local/python3
(prefix表示安装的路径,我安装在/usr/local中,也可以安装其他地方)
编译并安装make && make install
创建软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
验证安装成功
python3 -V
pip3 -V
修改pip源
mkdir ~/.pip/
cd ~/.pip/
vi pip.conf
在pip.conf中添加内容
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
最终的版本
[root@localhost Python-3.8.1]# python3 -V
Python 3.8.1
[root@localhost Python-3.8.1]# pip3 -V
pip 19.2.3 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)