> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# PGVector 集成

> 使用 LangChain Python 与 PGVector 进行集成。

本页面介绍如何在 LangChain 中使用 Postgres [PGVector](https://github.com/pgvector/pgvector) 生态系统。
它分为两部分：安装和设置，然后是特定 PGVector 包装器的参考。

## 安装

* 使用 `pip install pgvector` 安装 Python 包

## 设置

1. 第一步是创建一个已安装 `pgvector` 扩展的数据库。

   请按照 [PGVector 安装步骤](https://github.com/pgvector/pgvector#installation) 中的步骤安装数据库和扩展。docker 镜像是最简单的入门方式。

## 封装

### VectorStore

存在一个围绕 Postgres 向量数据库的封装，允许您将其用作向量存储，
无论是用于语义搜索还是示例选择。

要导入此向量存储：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_community.vectorstores.pgvector import PGVector
```

### 用法

有关 PGVector 封装的更详细逐步指南，请参阅 [此笔记本](/oss/python/integrations/vectorstores/pgvector)

***

<div className="source-links">
  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/i18n\zh-CN\oss\python\integrations\providers\pgvector.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>

  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>
</div>
