Sentry-python: sentry-sdk==19.0 init throws RuntimeError on python3.6

Created on 13 Oct 2020  路  11Comments  路  Source: getsentry/sentry-python

import sentry_sdk

...

sentry_sdk.init(
        dsn,
        environment=env,
        debug=True,
)
/usr/local/lib/python3.6/site-packages/sentry_sdk/hub.py:106: in _init
    client = Client(*args, **kwargs)  # type: ignore
/usr/local/lib/python3.6/site-packages/sentry_sdk/client.py:86: in __init__
    self._init_impl()
/usr/local/lib/python3.6/site-packages/sentry_sdk/client.py:132: in _init_impl
    "auto_enabling_integrations"
/usr/local/lib/python3.6/site-packages/sentry_sdk/integrations/__init__.py:119: in setup_integrations
    type(integration).setup_once()
/usr/local/lib/python3.6/site-packages/sentry_sdk/integrations/flask.py:75: in setup_once
    request_started.connect(_request_started)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <flask.signals._FakeSignal object at 0x7fc514b484e0>, args = (<function _request_started at 0x7fc515228840>,), kwargs = {}

    def _fail(self, *args, **kwargs):
        raise RuntimeError(
>           "Signalling support is unavailable because the blinker"
            " library is not installed."
        )
E       RuntimeError: Signalling support is unavailable because the blinker library is not installed.

/usr/local/lib/python3.6/site-packages/flask/signals.py:39: RuntimeError

It can be fixed if blinker is manually installed, please add blinker to sentry-sdk dependencies.

Most helpful comment

Using auto_enabling_integrations=False in sentry_sdk.init works for me.
Example:
```
sentry_sdk.init(settings.SENTRY_DSN, auto_enabling_integrations=False)
````

All 11 comments

Please don't add blinker to sentry-sdk dependencies, since not everyone is using a flask app.

The question from my POV is why Sentry assumes that if Flask is present, it should load its integration? And second, since flask itself gracefully falls back if blinker is absent, shouldn't sentry do the same?

Starting with Flask 0.6, there is integrated support for signalling in Flask. This support is provided by the excellent blinker library and will gracefully fall back if it is not available.

The docs tell you to install with the Flask extra which will pull blinker in https://docs.sentry.io/platforms/python/guides/flask/

Blinker is required for basic functionality, there is no possible fallback other than to stop working entirely.

I am also having this error with the upgrade. While I have Flask installed I am not using the flask plugin with sentry (I use sentry just with starlette).

Ah I see, 19.0. @HazAT @lobsterkatie can you deal with this? We should attempt to import blinker and raise DidNotEnable if it is not importable, inside of the flask integration.

Using auto_enabling_integrations=False in sentry_sdk.init works for me.
Example:
```
sentry_sdk.init(settings.SENTRY_DSN, auto_enabling_integrations=False)
````

Please, set auto_enabling_integrations to False by default

I'm getting this error with Django integration.

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
    integrations=[DjangoIntegration()],
    traces_sample_rate=1.0,
    send_default_pii=True
)
File "/opt/project/aton-backend/settings/local.py", line 5, in <module>
  sentry_sdk.init(
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/hub.py", line 106, in _init
  client = Client(*args, **kwargs)  # type: ignore
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/client.py", line 86, in __init__
  self._init_impl()
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/client.py", line 128, in _init_impl
  self.integrations = setup_integrations(
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/__init__.py", line 119, in setup_integrations
  type(integration).setup_once()
File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/flask.py", line 75, in setup_once
  request_started.connect(_request_started)
File "/usr/local/lib/python3.8/site-packages/flask/signals.py", line 38, in _fail
  raise RuntimeError(
RuntimeError: Signalling support is unavailable because the blinker library is not installed.

Setting _auto_enabling_integrations_ to _False_ solved the issue.

Fix is otw

Hey, sorry for the delay. 0.19.1 is out which fixes this issue.

Thanks @untitaker for the fix!

pip install --upgrade 'sentry-sdk[flask]' worked for me.

Was this page helpful?
0 / 5 - 0 ratings