简介
基于 python-build-standalone 项目,一键构建 Python 可移植/离线运行环境。自动识别 x86_64 和 arm64 架构,支持 pip 依赖安装,最终打包为可分发的 .tar.gz 压缩包。
适用场景
- 离线服务器需要 Python 但无法联网安装
- 携带特定 Python 版本 + 依赖的部署场景
- 不想污染系统 Python 环境
推荐镜像
GitHub 加速(国内服务器推荐使用 -m 参数):
https://gh-proxy.com/(推荐)https://ghproxy.net/https://mirror.ghproxy.com/
pip 镜像源(使用 -i 参数):
https://pypi.tuna.tsinghua.edu.cn/simple(默认)https://mirrors.aliyun.com/pypi/simple/https://pypi.mirrors.ustc.edu.cn/simple/
参数说明
| 参数 | 默认值 | 说明 |
|---|---|---|
-v |
3.12.12 |
Python 版本号 |
-t |
20260114 |
Release Tag |
-m |
无 | GitHub 加速镜像,推荐 https://gh-proxy.com/ |
-r |
无 | requirements.txt 路径 |
-i |
https://pypi.tuna.tsinghua.edu.cn/simple |
pip 镜像源 |
用法
仅构建 Python 环境
bash create-portable-python.sh
使用镜像加速(国内推荐)
bash create-portable-python.sh -m https://gh-proxy.com/
构建环境 + 安装依赖 + 自定义 pip 源
bash create-portable-python.sh -r requirements.txt -m https://gh-proxy.com/