# jinja2.exceptions.TemplateNotFound: index.html

- **ID:** `python/flask-jinja2-template-not-found`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

模板文件不在应用根目录下的 `templates/` 目录中，或应用以错误的 `root_path` 创建。

## 版本兼容性

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

## 解决方案

1. **** (97% 成功率)
   ```
   project/
  app.py
  templates/index.html
app = Flask(__name__, template_folder='templates')
   ```
2. **** (85% 成功率)
   ```
   app.jinja_loader.searchpath.append('/abs/path/templates')
   ```

## 无效尝试

- **** — Bypasses loader but loses autoescape/extends; brittle path handling. (70% 失败率)
- **** — Reload flag only affects change detection, not lookup. (90% 失败率)
