> 技术文档 > 在Windows环境下,不使用Docker,本地部署和启动开源项目Ragflow的源代码_ragflow非docker部署

在Windows环境下,不使用Docker,本地部署和启动开源项目Ragflow的源代码_ragflow非docker部署

        在当前AI领域中,基于检索增强生成(RAG)的应用备受关注,而开源项目RAGFlow因其高效精准的文档处理成为了一个热门选择。不过,由于其快速的版本迭代,可能会存在一些Bug,并且在实际项目落地时通常需要根据具体需求对源码进行定制化修改。遗憾的是,RAGFlow官方尚未提供针对Windows开发环境的详细文档。因此,在本地部署过程中,我整理了一份详细的记录,希望能够为有类似需求的开发者提供参考。

一、RAGFlow Python 环境配置

确保您的Python版本符合以下要求:

  • Python 版本:>=3.10,<3.13

二、Poetry 下载与安装

使用 Poetry 来管理 Python 依赖。首先,通过 pip 安装 Poetry:

pip install poetry

验证安装是否成功:

poetry --version

三、安装 Python 依赖

  1. 以管理员身份启动 Anaconda Prompt

    为了确保权限足够,建议以管理员身份启动 Anaconda Prompt。

2、切换到ragflow运行环境

(base) C:\\Windows\\System32>D:(base) D:>conda activate ragflow(ragflow) D:>cd D:\\WorkSpace\\ForAi\\pythod\\ragflow

3、在ragflow根目录下运行poetry安装依赖命令

# 安装所有默认依赖poetry install1. akshare (1.15.53) 安装失败尝试更新 Poetry 的锁文件:poetry lock --no-cache --regenerate 或者更新 akshare 到最新版本poetry update --no-cache akshare 2. fasttext (0.9.3) 安装失败错误原因:fasttext 的编译过程中出现 C++ 标准兼容性问题(需要 C++17 支持),且依赖的 string_view 未正确引入。此外,你的系统可能缺少编译工具链(如 MSVC)。关键错误信息:error C2039: \"string_view\": 不是 \"std\" 的成员 (表示编译器无法找到 C++17 的 std::string_view)解决方案:从第三方源安装(如 conda):conda install -c conda-forge fasttext 3. pyicu (2.14) 安装失败错误原因:pyicu 需要系统安装 ICU 库(国际化组件),但你的系统缺少 ICU 的开发头文件和工具(如 icu-config 或 pkg-config)。conda install -c conda-forge pyicu # 安装 full 组中的依赖poetry install -E full 或者 poetry install --with full 

四、前端启动

1、前端web服务器nginx

默认在目录下提供的配置文件是linux的,需要改成windows

nginx.conf

# user 指令在 Windows 上不支持,注释掉或删除# user root;worker_processes auto;# 修改日志路径为 Windows 路径error_log D:/dockerData/ragflow/nginx-1.21.1/logs/error.log notice;pid D:/dockerData/ragflow/nginx-1.21.1/logs/nginx.pid;events { worker_connections 1024;}http { # 修改 mime.types 文件路径为 Windows 路径 include D:/dockerData/ragflow/nginx-1.21.1/conf/mime.types; default_type application/octet-stream; log_format main \'$remote_addr - $remote_user [$time_local] \"$request\" \'\'$status $body_bytes_sent \"$http_referer\" \'\'\"$http_user_agent\" \"$http_x_forwarded_for\"\'; # 修改访问日志路径为 Windows 路径 access_log D:/dockerData/ragflow/nginx-1.21.1/logs/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; client_max_body_size 128M; # 包含自定义配置文件 include D:/dockerData/ragflow/nginx-1.21.1/conf/ragflow.conf;}

proxy.conf

这个配置文件不做修改

ragflow.conf

server { listen 80; server_name _; # 设置根目录为 Windows 路径 root D:/WorkSpace/ForAi/pythod/ragflow/web/dist; gzip on; gzip_min_length 1k; gzip_comp_level 9; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; gzip_disable \"MSIE [1-6]\\.\"; location ~ ^/(v1|api) { proxy_pass http://127.0.0.1:9380; include proxy.conf; } location / { index index.html; try_files $uri $uri/ /index.html; } # Cache-Control: max-age~@~AExpires location ~ ^/static/(css|js|media)/ { expires 10y; access_log off; }}

2、前端项目build

我使用的nodejs版本是 20.15.0 如果你本地有多个nodejs版本可以使用nvm管理切换

# 进入web目录下(ragflow) D:\\WorkSpace\\ForAi\\pythod\\ragflow>cd web# 安装前端依赖npm install# build项目npm run build

可以看到web目录下多了个dist,ragflow.conf配置文件里需要配置这个目录

3、启动nginx

D:\\dockerData\\ragflow\\nginx-1.21.1>start nginx

五、下载模型

找到根目录下的download_deps.py直接运行

依赖安装会比较慢

运行完根目录下多了这些文件

六、后端项目启动

1、配置mysql、redis、minio、es、infinity

2、启动项目

需要启动两个文件

(1)api下的ragflow_server.py

(2)rag/svr下的task_executor.py

在启动时遇到了文件是utf-8格式,默认使用的是gbk,我处理方式是直接改了源码,把文件处理的格式改成了utf-8

import osimport jsoncurrent_file_path = os.path.dirname(os.path.abspath(__file__))json_file_path = os.path.join(current_file_path, \"res/good_sch.json\")with open(json_file_path, \"r\", encoding=\"utf-8\") as file: GOOD_SCH = json.load(file)

import osimport jsoncurrent_file_path = os.path.dirname(os.path.abspath(__file__))# 读取 corp.tks.freq.json 文件with open(os.path.join(current_file_path, \"res/corp.tks.freq.json\"), \"r\", encoding=\"utf-8\") as file: CORP_TKS = json.load(file)# 读取 good_corp.json 文件with open(os.path.join(current_file_path, \"res/good_corp.json\"), \"r\", encoding=\"utf-8\") as file: GOOD_CORP = json.load(file)# 读取 corp_tag.json 文件with open(os.path.join(current_file_path, \"res/corp_tag.json\"), \"r\", encoding=\"utf-8\") as file: CORP_TAG = json.load(file)

cnvs = json.load(open(os.path.join(dir, fnm), \"r\", encoding=\"utf-8\"))

七、以上步骤做完即可通过http://127.0.0.1访问