# Python SDK

Aptos 提供了一个轻量级维护的官方 Python SDK。它已经上传到了 [PyPi](https://pypi.org/project/aptos-sdk/)，源代码在 [Aptos-core github 仓库](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/python/sdk)。Python SDK 的大部分功能与 [Typescript SDK](/aptos-kai-fa-zhe-wen-dang/sdks/typescript.md) 一致。Python SDK 的主要目的是帮助 Python 开发者快速熟悉 Aptos，并作为 Aptos 教程的补充。

### 安装 Python SDK

Python SDK 既可以通过 `pip` 安装，也可以基于源代码安装，甚至可以嵌入到您已有的 python 工程中。

#### 通过 `pip` 安装

```bash
pip3 install aptos-sdk
```

`aptos-sdk` 将被安装在本地的软件包目录下。例如，在 MacOS 上，你会在 `~/Library/Python/3.8/lib/python/Site-packages/aptos_sdk` 目录下找到 `aptos-sdk`。

#### 基于源代码安装

```bash
git clone <https://github.com/aptos-labs/aptos-core>
cd aptos-core/ecosystem/python/sdk
python3 setup.py install --user
```

#### 嵌入到现有的 Python 工程下

若要将 `aptos-sdk` 的嵌入到现有的 python 工程中，将[源代码仓库](https://github.com/aptos-labs/aptos-core/tree/main/ecosystem/python/sdk/aptos_sdk)中的 aptos\_sdk 构建产物复制到现有的 Python 工程下即可：

```
cd /path/to/python/project
cp -r /path/to/aptos-core/ecosystem/python/sdk/aptos_sdk aptos_sdk
```

### 使用 Aptos Python SDK

使用 Aptos Python SDK 的代码实例可参考[开发者教程](/aptos-kai-fa-zhe-wen-dang/aptos-kai-fa-zhe-wen-dang.md)。


---

# 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://gushi10546.gitbook.io/aptos-kai-fa-zhe-wen-dang/sdks/python-sdk.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.
