# jinja2.exceptions.TemplateNotFound: index.html

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

## 根因

Jinja2Templates 目录不包含该模板，或目录路径相对于工作目录错误。

## 版本兼容性

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

## 解决方案

1. **** (93% 成功率)
   ```
   templates = Jinja2Templates(directory=Path(__file__).parent / 'templates')
   ```
2. **** (85% 成功率)
   ```
   Verify file exists: print(list((Path(__file__).parent/'templates').iterdir()))
   ```

## 无效尝试

- **** — Trailing slash can cause double-slash path issues in some versions. (40% 失败率)
- **** — Breaks deployment layout and packaging. (60% 失败率)
