CentOS 7源码安装Python3.8
作者:互联网
1.安装依赖包
yum groupinstall "Development tools"
yum -y install gcc libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
2.下载对应的安装包
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz (官方地址,很慢)
wget https://npmmirror.com/mirrors/python/3.8.12/Python-3.8.12.tgz (阿里镜像,建议使用)
3.解压并安装python
# 解压源码包
tar -zxvf Python-3.8.12.tgz
# 创建安装目录
mkdir -p /usr/local/python38
# 进入python解压目录
cd Python-3.8.12/
# 配置安装目录
./configure --prefix=/usr/local/python38
# 编译并安装
make && make install
4.添加python软链接
这里不建议修改默认的软链接,因为yum等软件会使用到默认的python2版本,如果修改了默认的软链接,需要修改yum源码才能让yum正常运行
ln -s /usr/local/python38/bin/python3.8 /usr/bin/python3
ln -s /usr/local/python38/bin/pip3.8 /usr/bin/pip3
终于安装完了,来测试一下吧
python3 --version
pip3 -V
标签:12,CentOS,python,devel,源码,yum,Python3.8,3.8,usr 来源: https://www.cnblogs.com/fengwunian/p/15501989.html