python config_error ai_generated true

错误:无法打开 requirements 文件:[Errno 2] 没有那个文件或目录:'requirements.txt'

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

ID: python/pip-requirements-file-not-found

其他格式: JSON · Markdown 中文 · English
80%修复率
85%置信度
0证据数
2025-01-10首次发现

版本兼容性

版本状态引入弃用备注
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

指定的 requirements 文件在当前工作目录中不存在。

English

The specified requirements file does not exist in the current working directory.

generic

解决方案

  1. 95% 成功率 Check the current directory and create the file if needed
    ls && echo 'mypackage' > requirements.txt && pip install -r requirements.txt
  2. 90% 成功率 Specify the full path to the requirements file
    pip install -r /path/to/requirements.txt

无效尝试

常见但无效的做法:

  1. Creating an empty requirements.txt file 80% 失败

    An empty file will install nothing, but the error is about a missing file.

  2. Using a different file name like require.txt 90% 失败

    pip expects the exact filename; it won't auto-detect.