# 安装

## 安装

### 从 PyPI 安装

通常情况下，这是您的首选安装方式。

{% hint style="info" %}
请注意，如果当前操作系统环境已同时安装 Python 2 和 Python 3 版本，通常情况下 Python 软件包管理器对应的 Shell 命令为 pip3，而不是 pip。
{% endhint %}

借助 Python 软件包管理器，您可以快速安装 Tencent Cloud SDK for Python：

```bash
pip install tencent-cloud-sdk
```

如果您只想安装并集成所需 Tencent Cloud 产品，可以采用拆分安装的方式获取部分 Tencent Cloud SDK for Python。首先我们需要安装基础软件包，因为大多数 Tencent Cloud 产品软件包依赖它们。

```bash
pip install tencent-cloud-sdk-auth
pip install tencent-cloud-sdk-core
```

然后安装所需 Tencent Cloud 产品对应的产品软件包。例如 无服务器云函数 的产品软件包：

```bash
pip install tencent-cloud-sdk-serverless-functions
```

通常情况下，我们建议您直接选取并安装所需 Tencent Cloud 产品软件包，被安装的产品软件包将自动安装其依赖的其他软件包，这也包括基础软件包。

如果您仅希望在当前项目目录安装 Tencent Cloud SDK for Python：

```bash
pip install tencent-cloud-sdk -t .
```

### 从源代码安装

首先我们需要安装用于构建 Tencent Cloud SDK for Python 软件包的依赖软件包：

```bash
pip install setuptools
pip install wheel
```

然后从 Tencent Cloud SDK for Python 的 GitHub 仓库克隆开放源代码实现：

```bash
git clone https://github.com/nobody-night/tencent-cloud-sdk-python.git
```

接着导航到包含 Tencent Cloud SDK for Python 开放源代码实现的基础和产品软件包目录，然后将这些软件包逐一构建并安装：

```bash
cd tencent-cloud-sdk-python/packages

cd tencent-cloud-sdk-auth
python setup.py install

cd ../tencent-cloud-sdk-core
python setup.py install

cd ../tencent-cloud-sdk-serverless-functions
python setup.py install
```

在以上演示中我们已逐个构建并安装以下基础软件包和产品软件包：

| 软件包名称                                  | 软件包类型 | 产品名称                              |
| -------------------------------------- | ----- | --------------------------------- |
| tencent-cloud-sdk-auth                 | 基础软件包 | Tencent Cloud SDK for Python - 核心 |
| tencent-cloud-sdk-core                 | 基础软件包 | Tencent Cloud SDK for Python - 核心 |
| tencent-cloud-sdk-serverless-functions | 产品软件包 | Tencent Cloud - 无服务器云函数           |

## 卸载

如果您采用完整安装方式获取并安装 Tencent Cloud SDK for Python：

```bash
pip uninstall tencent-cloud-sdk
```

如果您采用拆分安装方式获取并安装 Tencent Cloud SDK for Python，您需要逐个卸载已安装的 Tencent Cloud SDK 产品软件包，例如 无服务器云函数 产品软件包：

```bash
pip uninstall tencent-cloud-sdk-serverless-functions
```

最后卸载 Tencent Cloud SDK for Python 的基础软件包：

```bash
pip uninstall tencent-cloud-sdk-core
pip uninstall tencent-cloud-sdk-auth
```

## 源代码

我们将 Tencent Cloud SDK for Python 的源代码实现托管在 GitHub 开放访问仓库中，您可以前往 <https://github.com/nobody-night/tencent-cloud-sdk-python> 获取。


---

# 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://smallso.gitbook.io/tencent-cloud-sdk/python-install.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.
