前言
由于CentOS7本身就需要安装Python2.7.5,而且这个Python2不能被删除,因为有很多系统命令,比如yum都要用到。
which python
Python3的方法
- 首先安装依赖包
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
- 安装python3
cd
# python官网下载xz后缀类型的源码包
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
mkdir -p /opt/python/python3
tar -xvJf Python-3.8.5.tar.xz && cd Python-3.8.5/
# 编译配置
./configure --prefix=/opt/python/python3
# 编译
make && make install
# 创建软连接
ln -s /opt/python/python3/bin/python3 /usr/bin/python3
ln -s /opt/python/python3/bin/pip3 /usr/bin/pip3
# 验证
python3 --version
# 收尾
cd && rm -rf Python-3.8.5 && mv Python-3.8.5.tar.xz /opt/python/Python-3.8.5.tar.xz
原文地址:
https://blog.csdn.net/weixin_44263973/article/details/127937059
标签:python,devel,xz,Python,python3,安装,3.8 From: https://www.cnblogs.com/hhddd-1024/p/17061383.html