CentOS7 使用yum安装python3.7

配置yum包管理

yum 换源

# 备份原来的repo文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 下载阿里云的源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 生成缓存
yum clean all
yum makecache

⚠️阿里云的CentOS8不要换源

yum更新

sudo yum -y update

安装yum扩展

sudo yum -y install yum-utils

安装CentOS开发工具

sudo yum -y groupinstall development

安装python3

安装python的yum依赖

yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc

下载python3.7安装包

# 将python3.7安装包,下载到/usr/local/src文件夹下
cd /usr/local/src/

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz

解压python3.7文件夹

# 解压
tar xvf Python-3.7.0.tar.xz
# 重命名文件夹
mv Python-3.7.0 python3
# 进入到解压出的文件夹
cd python3

编译python3,7

./configure --prefix=/usr/local/python3

将python3.7 安装到/usr/local/python3 下

make && make install

👑配置完成👑

posted @ 2021-01-21 16:23  VanGy  阅读(11094)  评论(3编辑  收藏  举报