Windows下使用源码和Conda搭建GraphRAG指南

Windows下使用源码和Conda搭建GraphRAG指南

点击查看【GraphRAG的使用

1. 创建和激活conda环境

bash 复制代码
conda create --name=graphrag_env
conda activate graphrag_env

2. 安装系统依赖

GraphRAG需要一些系统级依赖:

1)安装 CMake (如果尚未安装)

从【这个地址】下载并安装CMake,执行以下命令并看到以下信息表示安装成功:

bash 复制代码
C:\Users\Administrator>cmake --version
cmake version 3.31.10
CMake suite maintained and supported by Kitware (kitware.com/cmake).
C:\Users\Administrator>

2)安装Microsoft C++ Build Tools

从【这个地址】下载并安装 Visual Studio Build Tools(或 Visual Studio Community)。

下载后,双击运行【vs_BuildTools.exe】,该程序执行完下载后进入到安装界面,此时,选择【单个组件】选项卡,在筛选框中输入【C++ Build Tools】关键字进行筛选,勾选后点击【安装】按钮完成安装。

3. 安装PyTorch

bash 复制代码
# 根据您的CUDA版本选择合适的PyTorch安装命令
# 如果没有GPU,使用CPU版本

# CPU版本
conda install pytorch torchvision torchaudio cpuonly -c pytorch

# 或者使用pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

4. 克隆GraphRAG源码

bash 复制代码
# 克隆GraphRAG仓库
git clone https://github.com/microsoft/graphrag.git
cd graphrag

5. 安装GraphRAG

这里使用 pyproject.toml 进行安装,需要进入到 graphrag 目录,运行以下命令:

bash 复制代码
# 从源码安装
pip install -e .

# 或者直接使用pip安装(如果已发布到PyPI)
# pip install graphrag

6. 验证安装

graphrag 目录的同级,创建名为 graphrag_test 目录,并在该目录下创建测试脚本 test_installation.py 文件,内容如下:

python 复制代码
import sys
try:
    import graphrag
    print("✓ GraphRAG导入成功")
    
    import torch
    print(f"✓ PyTorch版本: {torch.__version__}")
    
    import networkx as nx
    print(f"✓ NetworkX版本: {nx.__version__}")
    
    print("✓ 所有依赖安装成功!")
    
except ImportError as e:
    print(f"✗ 导入错误: {e}")
    sys.exit(1)

运行测试:

bash 复制代码
cd ../graphrag_test/
python test_installation.py
相关推荐
埃博拉酱4 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
唐宋元明清21885 天前
.NET 本地Db数据库-技术方案选型
windows·c#
加号35 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
tryCbest5 天前
Windows环境下配置pip镜像源
windows·pip
呉師傅5 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
百事牛科技5 天前
保护文档安全:PDF限制功能详解与实操
windows·pdf
一个人旅程~5 天前
如何用命令行把win10/win11设置为长期暂停更新?
linux·windows·经验分享·电脑
一个假的前端男5 天前
[特殊字符] Flutter 安装完整指南 Windows—— 2026最新版
windows·flutter
倚肆5 天前
在 Windows Docker 中安装并配置 Nginx (映射 Windows 端口与路径)
windows·nginx·docker
破无差5 天前
拯救你的C盘
windows