python - 从源码编译安装到制作安装包
1. python源码安装步骤
(1)源码下载地址:https://chuna2.787528.xyz/zjxcyr/p/18104925
(2)解压源码编译和安装:
安装依赖:yum install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel
源码编译和安装:
./configure --prefix=~/python3 --with-openssl=/usr/include/openssl
make && make install
2. 安装包制作 - 打包前通过脚本批量修改shebang
cd ~/python3
>> cat execute.sh
find bin -type f -executable | while read f; do
if head -n1 "$f" | grep -q "^#!.*python"; then
sed -i '1s|.*python.*|#!/usr/bin/env python3|' "$f"
echo "Fixed: $f"
fi
done
制作安装包:
cd ~;
tar cvf python3.12.tar.gz python3
3. 安装测试
tar xvf python3.12.tar.gz
echo 'export PATH=~/python3/bin:$PATH' >> ~/.bash_profile
>> python --version
>> pip --version
浙公网安备 33010602011771号