You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ReadTheDocs无法找到requirements.txt问题求助

解决ReadTheDocs构建时找不到requirements.txt的问题

可能的原因及修复方案

1. 配置文件路径相对关系错误

你的.readthedocs.yaml放在docs目录下,而ReadTheDocs默认以仓库根目录作为构建工作目录。如果source文件夹实际在docs目录内,配置里的路径应该改为docs/source/requirements.txt,而非source/requirements.txt。

修改后的.readthedocs.yaml内容:

python:
  install:
    - requirements: docs/source/requirements.txt

2. 未将requirements.txt推送到远程仓库

本地存在文件但未同步到远程仓库时,ReadTheDocs构建时无法找到该文件。执行以下命令确认并推送:

# 检查文件是否被Git追踪
git status
# 若未追踪,添加并提交
git add docs/source/requirements.txt
git commit -m "Add requirements.txt"
git push

3. 未指定文档根目录

如果所有文档源文件都在docs目录下,需在.readthedocs.yaml中明确指定docs_dir,确保构建上下文正确:

build:
  docs_dir: docs

python:
  install:
    - requirements: source/requirements.txt

此时source/requirements.txt会相对于docs_dir设置的docs目录,对应实际路径docs/source/requirements.txt。

验证步骤

修改配置或推送文件后,重新触发ReadTheDocs构建,查看错误是否消失。

内容的提问来源于stack exchange,提问作者fengyang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 06:04:54