操作系统 : CentOS7.6.1810_x64
Python 版本 : 3.9.12
1、获取源代码
python官方网址: https://www.python.org/
源码下载地址:
或者直接wget :
wget https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tgz
2、编译及安装
解压文件:
安装依赖项:
yum install -y gcc bzip2 bzip2-devel ncurses openssl openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel libffi-devel
编译:
cd Python-3.9.12 ./configure --enable-optimozations --enable-shared --prefix=/usr/local/python39 make -j 4 make altinstall
安装完毕,会在 /usr/local/python39 部署python相关文件:
[root@host33 python39]# pwd /usr/local/python39 [root@host33 python39]# ls bin include lib share [root@host33 python39]#
启动脚本:
#! /bin/bash export CFLAGS="-I/usr/local/python39/include" export LDFLAGS="-L/usr/local/python39/lib" export LD_LIBRARY_PATH=/usr/local/python39/lib /usr/local/python39/bin/python3.9
启动效果:
3、制作安装包
安装需要的软件包(比如ipython):
/usr/local/python39/bin/python3.9 -m pip install ipython
打包二进制文件:
tar zcvf python39-centos7-bin.tar.gz python39
其它机器测试:
tar zxvf python39-centos7-bin.tar.gz cd python39 ./start.sh
本文涉及源码及预编译二进制文件,可以从百度网盘获取:
https://pan.baidu.com/s/156TSxGvvwK_2WQDCt_O8lg
关注微信公众号(聊聊博文,文末可扫码)后回复 2022072401 获取提取码。
原创文章,作者:wure,如若转载,请注明出处:https://blog.ytso.com/276673.html