Centos7.9 编译安装Python3

1、查看已安装python 版本

python -V

Centos7.9 编译安装Python3_第1张图片

当前版本为2.7.5 (因centos的yum依赖2.7版本 不建议卸载)
2、将python3上传到服务器并解压

tar -zxvf Python-3.10.6.tgz

Centos7.9 编译安装Python3_第2张图片

3、安装Python3编译的依赖包

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

Centos7.9 编译安装Python3_第3张图片

 4、进入Python3 目录

cd Python-3.10.6

Centos7.9 编译安装Python3_第4张图片

 5、配置Python3 安装目录

./configure --prefix=/opt/software/python  --with-openssl=/opt/software/openssl

Centos7.9 编译安装Python3_第5张图片

 6、编译并安装Python3

make
make install

Centos7.9 编译安装Python3_第6张图片

Centos7.9 编译安装Python3_第7张图片

7、编辑链接

ln -s /opt/software/python/bin/python3 /usr/bin/python3
ln -s /opt/software/python/bin/pip3 /usr/bin/pip3

Centos7.9 编译安装Python3_第8张图片

8、查看安装是否成功

python3 -V
pip3 -V
pip3 list

Centos7.9 编译安装Python3_第9张图片

你可能感兴趣的:(Python,CentOS,python,开发语言)