Skip to content

RAGFlow 开发环境搭建踩坑(Windows 系统)

下午 Clone 了 RAGFlow v0.21.0,计划在本地 Windows 搭建好开发环境,前后遇到了 pyicu、datrie 报错,下载模型报错等问题,记录一下踩坑过程。


克隆仓库

直接在 release 页面下载的 v0.21.0 版本源码。

安装依赖

执行下方命令安装依赖,pyicu 依赖报错,尝试使用 pip install pyicu==2.15.3 也依然错误。

shell
cd ragflow
uv sync --all-extras
shell
Resolved 434 packages in 2ms
  x Failed to build `pyicu==2.15.3`
  |-> The build backend returned an error
  `-> Call to `setuptools.build_meta.build_wheel` failed (exit code: 1)

      [stdout]

      Building pyicu 2.15.3 for ICU 2.15.3 (max ICU major version supported: 77)

      running bdist_wheel
      running build
      running build_py
      copying py\icu\__init__.py -> build\lib.win-amd64-cpython-311\icu
      running build_ext
      building 'icu._icu_' extension

      [stderr]
      C:\Users\charl\AppData\Local\uv\cache\builds-v0\.tmpKnwXhJ\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option: 'test_suite'  
        warnings.warn(msg)
      C:\Users\charl\AppData\Local\uv\cache\builds-v0\.tmpKnwXhJ\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option:
      'tests_require'
        warnings.warn(msg)
      C:\Users\charl\AppData\Local\uv\cache\builds-v0\.tmpKnwXhJ\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.  
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        self._finalize_license_expression()
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

      hint: This usually indicates a problem with the package or the build environment.
  help: `pyicu` (v2.15.3) was included because `ragflow` (v0.21.0) depends on `pyicu

关键错误如下:

shell
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

我的机器没有 Microsoft Visual C++ 14.0,所以无法编译安装,我不太想在这台机器安装,所以寻找 wheel。(如果你想安装可自行搜索相关教程)

安装 pyicu wheel

查找并使用 wheel 安装 pyicu。(在 pyicu wheel 下载 中,下载符合你 Python 版本和操作系统的 wheel,我的 Python 版本是 3.11.x,所以下载 pyicu-2.15.3-cp311-cp311-win_amd64.whl

shell
# 我导入到了 PyCharm 中,已经自动配置了虚拟环境。如果你没有,需要先执行 uv venv
.venv\Scripts\activate
uv pip install .\pyicu-2.15.3-cp311-cp311-win_amd64.whl
shell
Resolved 1 package in 8ms
Prepared 1 package in 72ms
░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels...                                                                                                                               warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.                                                                          
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 1 package in 23ms
 + pyicu==2.15.3 (from file:///D:/ragflow/pyicu-2.15.3-cp311-cp311-win_amd64.whl)

重新执行依赖安装命令,安装到 datrie 依赖又报错了。

shell
uv sync --all-extras
shell
Resolved 434 packages in 2ms
  x Failed to build `datrie==0.8.2`
  |-> The build backend returned an error                                                                                                                                     
  `-> Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit code: 1)

      [stdout]
      running bdist_wheel
      running build
      running build_clib
      building 'datrie' library

      [stderr]
      C:\Users\charl\AppData\Local\uv\cache\builds-v0\.tmprkBjZ8\Lib\site-packages\setuptools\_distutils\dist.py:289: UserWarning: Unknown distribution option:
      'tests_require'
        warnings.warn(msg)
      C:\Users\charl\AppData\Local\uv\cache\builds-v0\.tmprkBjZ8\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.  
      !!

              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:

              License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)

              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************

      !!
        self._finalize_license_expression()
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

      hint: This usually indicates a problem with the package or the build environment.
  help: `datrie` (v0.8.2) was included because `ragflow` (v0.21.0) depends on `datrie

安装 datrie wheel

继续寻找 datrie wheel,但找了半天也没找到,最后让一个有环境的朋友安装 datrie 后发我了一份 wheel。

20251024-01

shell
uv pip install .\datrie-0.8.2-cp311-cp311-win_amd64.whl
shell
Resolved 1 package in 2ms
Prepared 1 package in 10ms
░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels...                                                                                                                               warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance.                                                                          
         If the cache and target directories are on different filesystems, hardlinking may not be supported.
         If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning.
Installed 1 package in 8ms
 + datrie==0.8.2 (from file:///D:/ragflow/datrie-0.8.2-cp311-cp311-win_amd64.whl)

重新执行依赖安装命令,终于顺畅安装完了。

下载模型

然后执行 download_deps.py 下载模型等数据,前两个下载都没问题,第三个从 huggingface 下载模型出错了。

20251024-02

搜了下方案,将 download_deps.py 中的 download_model 调整了一下,替换成国内镜像,然后重新下载。(可以在 main 方法中把之前下载成功的部分的下载代码注释掉)。

shell
def download_model(repo_id):
    local_dir = os.path.abspath(os.path.join("huggingface.co", repo_id))
    os.makedirs(local_dir, exist_ok=True)
    endpoint = "https://hf-mirror.com"
    snapshot_download(repo_id=repo_id, endpoint=endpoint, local_dir=local_dir, local_dir_use_symlinks=False)

等了很长时间才下载完,中间还有几次超时,反复重试。(好几 G 的资源下载)

启动 api 接口

启动 api/ragflow_server.py

启动 RAG 服务

启动 rag/svr/task_executor.py

参考资料

  1. RAGFlow-开发环境搭建(pyicu报错/无法启动等问题):https://blog.csdn.net/weixin_41957432/article/details/147296975
  2. Windows 下使用 pip 安装 pyicu 报错解决全记录:https://blog.csdn.net/zwx19972424/article/details/149632173
  3. Windows 下使用 uv 安装 pyicu 报错解决全记录:构建失败与 Wheel 安装绕过方案:https://blog.csdn.net/gs80140/article/details/148144856