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

推荐订阅源

U
Unit 42
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
S
Secure Thoughts
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News | PayPal Newsroom
Application and Cybersecurity Blog
Application and Cybersecurity Blog
O
OpenAI News
S
Security @ Cisco Blogs
宝玉的分享
宝玉的分享
Hacker News: Ask HN
Hacker News: Ask HN
T
Troy Hunt's Blog
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
有赞技术团队
有赞技术团队
TaoSecurity Blog
TaoSecurity Blog
Help Net Security
Help Net Security
Latest news
Latest news
NISL@THU
NISL@THU
S
Security Affairs
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 聂微东
AI
AI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
小众软件
小众软件
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
AWS News Blog
AWS News Blog
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
I
InfoQ
Schneier on Security
Schneier on Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Exploit Database - CXSecurity.com
IT之家
IT之家
T
Threatpost
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
腾讯CDC
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
N
News and Events Feed by Topic
L
LINUX DO - 最新话题
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
H
Heimdal Security Blog
S
SegmentFault 最新的问题

毛俊的博客

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

(完)