ubuntu22.04下python3.12拆分成多个功能包用途
python3.12名字
- ubuntu22.04
python3.12/noble-updates,noble-security,now 3.12.3-1ubuntu0.11 arm64 [installed,automatic]
Interactive high-level object-oriented language (version 3.12)
python3.12-dbg/noble-updates,noble-security 3.12.3-1ubuntu0.11 arm64
Debug Build of the Python Interpreter (version 3.12)
python3.12-dev/noble-updates,noble-security,now 3.12.3-1ubuntu0.11 arm64 [installed,automatic]
Header files and a static library for Python (v3.12)
python3.12-doc/noble-updates,noble-security 3.12.3-1ubuntu0.11 all
Documentation for the high-level object-oriented language Python (v3.12)
python3.12-examples/noble-updates,noble-security 3.12.3-1ubuntu0.11 all
Examples for the Python language (v3.12)
python3.12-full/noble-updates,noble-security 3.12.3-1ubuntu0.11 arm64
Python Interpreter with complete class library (version 3.12)
python3.12-minimal/noble-updates,noble-security,now 3.12.3-1ubuntu0.11 arm64 [installed,automatic]
Minimal subset of the Python language (version 3.12)
python3.12-nopie/noble-updates,noble-security 3.12.3-1ubuntu0.11 arm64
Python interpreter linked without PIE (version 3.12)
python3.12-venv/noble-updates,noble-security 3.12.3-1ubuntu0.11 arm64
Interactive high-level object-oriented language (pyvenv binary, version 3.12)
解读python-xyz-zz
minimal + runtime
1.python3.12-minimal
这是 最小运行环境,系统组件依赖它。
只包含:
- Python 解释器核心
- 极少数基础模块
- 用于系统脚本运行
特点:
- 体积最小
- 系统启动脚本依赖
- 不适合开发环境
系统必须装它,否则 apt / system tools 会崩。
2.python3.12
这是标准运行时。
相比 minimal,多了:
- 常用标准库
- 正常运行 Python 程序所需模块
一般用户运行 Python:
1 | python3.12 script.py |
用的是这个包。
3.python3.12-dev
这是 编译 Python 扩展模块必须的。
包含:
- Python.h 头文件
- libpython 静态库
- 编译 C/C++ 扩展所需文件
如果你执行:
1 | pip install numpy |
需要本地编译时,就依赖它。
SRE/DevOps 场景:
容器构建 often 需要:
1 | apt install python3.12-dev build-essential |
4.python3.12-venv
用于创建虚拟环境:
1 | python3.12 -m venv venv |
没有它会报:
ensurepip is not available
生产 Python 项目基本都会装这个。
5.spython3.12-dbg
调试版本解释器:
特点:
- 启用 debug symbols
- 内存检测
- C 扩展调试
用于:
- gdb 调试 Python
- 查内存泄漏
- CPython 内部调试
普通用户不需要。
6.python3.12-doc
官方文档,本地 man/doc 文档。
服务器基本没人装。
7.python3.12-examples
官方示例代码。
教学用途。
8.python3.12-full
相当于:
python3.12 + venv + distutils + 常见标准模块
适合:
- 开发机
- 学习环境
- 不想缺模块的场景
服务器一般不用 full,而是按需装。
9.python3.12-nopie
PIE = Position Independent Executable
默认 Python 是 PIE 编译:
- 更安全(ASLR)
- 地址随机化
nopie:
- 关闭 PIE
- 某些嵌入式/调试场景用
- 性能或兼容性特殊需求
生产基本不用。
工作中常见组合
1.服务器/容器
1 | python3.12 |
系统自动会装:
1 | python3.12-minimal |
典型模式:
system python
↓
venv
↓
project deps
未来 Ubuntu 也在推动:
system python ≠ user python