惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
雷峰网
雷峰网
Recent Announcements
Recent Announcements
月光博客
月光博客
G
Google Developers Blog
腾讯CDC
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
T
Tenable Blog
云风的 BLOG
云风的 BLOG
W
WeLiveSecurity
博客园 - 【当耐特】
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 聂微东
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
MyScale Blog
MyScale Blog
K
Kaspersky official blog
T
The Blog of Author Tim Ferriss
Attack and Defense Labs
Attack and Defense Labs
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
aimingoo的专栏
aimingoo的专栏
I
Intezer
Vercel News
Vercel News
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
Latest news
Latest news
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
S
Security Affairs
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
博客园 - Franky
C
Cyber Attacks, Cyber Crime and Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
美团技术团队
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Security @ Cisco Blogs
L
LINUX DO - 热门话题
Know Your Adversary
Know Your Adversary
Project Zero
Project Zero
D
Docker
L
Lohrmann on Cybersecurity
F
Full Disclosure

毛俊的博客

Shell中的错误重定向和标准重定向 - 毛俊的博客 对终身会员软件停止服务的思考总结 - 毛俊的博客 Vue3项目搭建的4种方式 - 毛俊的博客 Kubernetes及其生态介绍和使用 - 毛俊的博客 MPV播放器默认快捷键 - 毛俊的博客 Markdown导出带大纲目录的Html - 毛俊的博客 Windows设置操作URI指令 - 毛俊的博客 极简生活可以尝试的实践 - 毛俊的博客 《不持有的生活》读书摘录 - 毛俊的博客 艾宾浩斯遗忘曲线复习计划表 - 毛俊的博客 Google搜索技巧 - 毛俊的博客 GitHub搜索技巧 - 毛俊的博客 运动类影视剧集清单 - 毛俊的博客 常用软件清单 - 毛俊的博客 COCA 20000词根词汇练习 - 毛俊的博客 少吃或不吃的食物 - 毛俊的博客 美军两分钟睡眠法 - 毛俊的博客 健康食物清单 - 毛俊的博客 Git客户端工具GitUi安装及使用 - 毛俊的博客
离线编译并安装 Python 3.7 - 毛俊的博客
毛 俊 · 2024-07-06 · via 毛俊的博客

下载

  1. 下载 Python 3.7 源代码

    Python 官方网站 下载 Python 3.7 的源代码:

    1
    wget https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz
  2. 下载依赖项

    • openssl-devel
    • bzip2-devel
    • libffi-devel
    • zlib-devel
    • xz-devel
    • sqlite-devel
    • readline-devel

    使用以下命令下载这些依赖项的 RPM 包:

    1
    yum install --downloadonly --downloaddir=./rpms openssl-devel bzip2-devel libffi-devel zlib-devel xz-devel sqlite-devel readline-devel

    将所有依赖项下载到 ./rpms 目录中,方便离线传输。

拷贝到离线服务器

将下载的 Python-3.7.12.tgz 文件和 rpms 目录中的 RPM 文件复制到离线服务器上。

安装依赖项

在离线服务器上安装依赖项:

1
2
cd /path/to/rpms
sudo yum localinstall *.rpm

解压并编译

  1. 解压 Python 源代码

    1
    2
    tar xzf Python-3.7.12.tgz
    cd Python-3.7.12
  2. 配置、编译并安装 Python

    1
    2
    sudo ./configure --enable-optimizations   --enable-shared
    sudo make altinstall

手动编译需要携带 --enable-shared参数,否则使用Pyinstarller打包软件的时候会报错:

1
2
3
4
5
6
7
8
9
raise IOError(msg)
OSError: Python library not found: libpython3.7m.so.1.0, libpython3.7.so.1.0, libpython3.7mu.so.1.0, libpython3.7.so, libpython3.7m.so
This means your Python installation does not come with proper shared library files.
This usually happens due to missing development package, or unsuitable build parameters of the Python installation.

* On Debian/Ubuntu, you need to install Python development packages:
* apt-get install python3-dev
* apt-get install python-dev
* If you are building Python by yourself, rebuild with `--enable

验证安装

验证 Python 3.7 是否安装成功:

1
python3.7 --version

看到输出内容为 Python 3.7.12

使用虚拟环境

建议在使用新的 Python 版本时创建虚拟环境:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 创建 Python 3.7 虚拟环境
python3.7 -m venv myenv

# 激活虚拟环境
source myenv/bin/activate

# 验证 Python 版本
python --version # 输出应该是 Python 3.7.x

# 升级 pip
pip install --upgrade pip

# 安装 pyinstaller
pip install pyinstaller

# 使用 pyinstaller 打包脚本
pyinstaller your_script.py

(完)