python:第二章:linux编译安装python(3.12.0)
一,查看当前python的版本
liuhongdi@lhdpc:~$ python3 --version
Python 3.11.6
二,安装的官方文档:
1,配置用的选项:
https://docs.python.org/zh-cn/3/using/configure.html
2,安装依赖包的文档
https://devguide.python.org/getting-started/setup-building/#install-dependencies
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/11/11/python-di-yi-ke-linux-bian-yi-an-zhuang-python-3-12/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
三,我们安装python最新版本的步骤:
1,安装依赖包:
root@lhdpc:/usr/local/source/Python-3.12.0# apt-get install build-essential gdb lcov pkg-config libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev uuid-dev zlib1g-dev
2,得到下载链接
访问官网的下载页面:
https://www.python.org/downloads/
我们在Gzipped source tarball这个链接上右击,选择:复制链接地址
3,从命令行下载:
创建源文件和安装文件的目录
liuhongdi@lhdpc:~$ sudo mkdir /usr/local/source
liuhongdi@lhdpc:~$ sudo mkdir /usr/local/soft
用wget下载我们所复制的下载链接
root@lhdpc:/usr/local/source# wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
4,解压缩:
root@lhdpc:/usr/local/source# tar -zxvf Python-3.12.0.tgz
5,配置:
root@lhdpc:/usr/local/source/Python-3.12.0# ./configure --prefix=/usr/local/soft/python3.12 --enable-optimizations
6,编译
root@lhdpc:/usr/local/source/Python-3.12.0# make
7,安装
root@lhdpc:/usr/local/source/Python-3.12.0# make install
四,安装完成后查看结果:
root@lhdpc:/usr/local/source/Python-3.12.0# /usr/local/soft/python3.12/bin/python3 --version
Python 3.12.0