# FileNotFoundError: [Errno 2] 没有这样的文件或目录: 'report.html'

- **ID:** `python/pytest-html-report-not-generated`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest-html 插件未生成报告文件，通常是因为插件未安装、输出路径不正确，或测试运行在报告生成前崩溃。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 4.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   pip install pytest-html
pytest --html=report.html --self-contained-html
   ```
2. **** (88% 成功率)
   ```
   import tempfile
import os

report_path = os.path.join(tempfile.gettempdir(), 'report.html')
# Run pytest with: --html=report_path
   ```

## 无效尝试

- **** — This creates an empty file that does not contain test results. The report will be useless. (95% 失败率)
- **** — This avoids the error but does not generate the report, defeating the purpose of using pytest-html. (90% 失败率)
