Skip to content

ImportError in starlette integration when jinja2 isn't installed (starlette 1.0.0) #5782

Closed

Description

@craigds

How do you use Sentry?

Self-hosted/on-premise

Version

2.55.0

Steps to Reproduce

After upgrading to starlette 1.0.0, we've started getting ImportErrors from sentry init.

pip freeze is gigantic but the relevant parts are:

  • Python 3.10.12
  • sentry-sdk==2.55.0
  • starlette==1.0.0
  • no jinja2

Expected Result

works nice and quiet like

Actual Result

...
  File "/app/thing/settings.py", line 924, in sentry_init_with_profiling
    return sentry_sdk.init(integrations=[])
  File "/venv/lib/python3.10/site-packages/sentry_sdk/_init_implementation.py", line 57, in _init
    client = sentry_sdk.Client(*args, **kwargs)
  File "/venv/lib/python3.10/site-packages/sentry_sdk/client.py", line 283, in __init__
    self._init_impl()
  File "/venv/lib/python3.10/site-packages/sentry_sdk/client.py", line 435, in _init_impl
    self.integrations = setup_integrations(
  File "/venv/lib/python3.10/site-packages/sentry_sdk/integrations/__init__.py", line 258, in setup_integrations
    type(integration).setup_once()
  File "/venv/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 137, in setup_once
    patch_templates()
  File "/venv/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 555, in patch_templates
    from starlette.templating import Jinja2Templates  # type: ignore
  File "/venv/lib/python3.10/site-packages/starlette/templating.py", line 28, in <module>
    raise ImportError("jinja2 must be installed to use Jinja2Templates") from _import_error
ImportError: jinja2 must be installed to use Jinja2Templates

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Mar 23, 2026
  2. linear-code commented on Mar 23, 2026

    @linear-code
  3. sentrivana commented on Mar 24, 2026

    @sentrivana
    Collaborator

    Thanks @craigds, taking a look.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Mar 24, 2026
  5. self-assigned this
    on Mar 24, 2026
  6. sentrivana commented on Mar 24, 2026

    @sentrivana
    Collaborator

    We already have a fix for this on main, so it'll be out with the next release soon!

  7. sentrivana commented on Mar 24, 2026

    @sentrivana
    Collaborator

    Out now in 2.56.0, thanks again for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions