3 python
3.1 下载
本教程基于系统centos8,下载python3.10.12版本
3.2 解压
tar -zxvf Python-3.10.12.tgz
3.3 下载依赖!
下载python10之前,需要确保有以下依赖
sudo 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
!! 有时会存在db4-devel找不到的问题,那是因为yum的资源包找不到该包,因此需要手动下载
-
搭建db4-devel依赖
wget https://pkgs.dyn.su/el8/base/x86_64/libdb4-4.8.30-30.el8.x86_64.rpm rpm -ivh libdb4-4.8.30-30.el8.x86_64.rpm wget https://pkgs.dyn.su/el8/base/x86_64/libdb4-devel-4.8.30-30.el8.x86_64.rpm rpm -ivh libdb4-devel-4.8.30-30.el8.x86_64.rpm
-
搭建libpcap-devel依赖,
如出现异常,可查看第三步
wget https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/libpcap-1.9.1-5.el8.x86_64.rpm rpm -ivh libpcap-1.9.1-5.el8.x86_64.rpm wget https://vault.centos.org/centos/8/PowerTools/x86_64/os/Packages/libpcap-devel-1.9.1-5.el8.x86_64.rpm rpm -ivh libpcap-devel-1.9.1-5.el8.x86_64.rpm
-
搭建libpcap出现以下错误,一般看操作系统,并不一定会出现
[root@VM-12-7-opencloudos software]# rpm -ivh libpcap-1.9.1-5.el8.x86_64.rpm warning: libpcap-1.9.1-5.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY Verifying... ################################# [100%] Preparing... ################################# [100%] package libpcap-14:1.9.1-5.oc8.x86_64 (which is newer than libpcap-14:1.9.1-5.el8.x86_64) is already installed file /usr/lib64/libpcap.so.1.9.1 from install of libpcap-14:1.9.1-5.el8.x86_64 conflicts with file from package libpcap-14:1.9.1-5.oc8.x86_64
- 主要的错误为file /usr/lib64/libpcap.so.1.9.1 from install of libpcap-14:1.9.1-5.el8.x86_64
conflicts with file from package libpcap-14:1.9.1-5.oc8.x86_64
,将libpcap-14:1.9.1-5.oc8.x86_64删除就行
[root@VM-12-7-opencloudos software]# yum list | grep pcap libpcap.x86_64 14:1.9.1-5.oc8 @BaseOS libpcap-debugsource.x86_64 14:1.9.1-5.el8 @System python3-pcapy.x86_64 0.11.5-8.el8 epel python3-pypcapkit.noarch 0.14.5-1.el8 epel [root@VM-12-7-opencloudos software]# sudo yum remove libpcap.x86_64
- 主要的错误为file /usr/lib64/libpcap.so.1.9.1 from install of libpcap-14:1.9.1-5.el8.x86_64
3.4 配置与安装
首先进入python的目录执行以下脚本
./configure --prefix=/usr/local/src/python3.10 --enable-optimizations # 第一选项指定需要安装目录,第二选项提高python性能
make & make install # 编译安装
3.5 编译安装出现的错误
若出现以下错误,则重新修改配置选项,重新安装编译
The necessary bits to build these optional modules were not found:
nis
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc pwd time
步骤:在python目录下进行
make clean # 清除编译结果
./configure --prefix=/usr/local/src/python3.10 --enable-optimizations --without-nis # 不选哟nis模块
make & make install # 重新编译安装