# 编译源码

对于 `Debian/Ubuntu`，执行：

```
sudo apt install -y zlib1g zlib1g-dev libffi-dev openssl libssl-dev
```

对于 `RedHat/CentOS/Fedora`，执行：

```
yum install -y zlib zlib-devel libffi-devel openssl openssl-devel
```

对于 `macOS`，执行：

```
xcode-select --install
```

## 编译、安装

进入 Python 源码根目录，执行以下命令：

```
./configure
make
make install
```

Python 将会被编译，并安装在默认目录中。若您希望将 Python 安装在特定目录，则需要在一开始修改 `configure` 命令为：

```
./configure --prefix=<Python要安装到的目录（绝对路径）>
```

在指定目录中:

* **bin 目录** 存放的是可执行文件
* **include 目录** 存放的是 Python 源码的头文件
* lib 目录存放的是 Python 标准库
  * **lib/python3.7/config-3.7m-{platform} 目录** 存放的是 libpython3.7m.a，该静态库用于使用 C 语言进行扩展。`{platform}` 代表平台，比如在 Mac OS 上为 “darwin”，在 Linux 上为 “x86\_64-linux-gnu”
* **share 目录** 存放的是帮助等文件

如需重新编译，请首先执行：

```
make clean
```

再执行本节开头处的命


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://im-qianuxn.gitbook.io/pytorch/ji-suan-ji/python-yuan-ma-yue-du/bian-yi-yuan-ma.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
