python
config_error
ai_generated
true
jinja2.exceptions.TemplateNotFound: index.html
ID: python/starlette-template-not-found
80%Fix Rate
88%Confidence
0Evidence
2024-04-21First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Jinja2Templates directory does not contain the template, or the directory path is wrong relative to the working directory.
generic中文
Jinja2Templates 目录不包含该模板,或目录路径相对于工作目录错误。
Workarounds
-
93% success
templates = Jinja2Templates(directory=Path(__file__).parent / 'templates')
-
85% success
Verify file exists: print(list((Path(__file__).parent/'templates').iterdir()))
Dead Ends
Common approaches that don't work:
-
40% fail
Trailing slash can cause double-slash path issues in some versions.
-
60% fail
Breaks deployment layout and packaging.