Skip to content

AttributeError: module 'channels' has no attribute '__version__' #5298

@javiertejero

Description

@javiertejero

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.49.0

Steps to Reproduce

If channels package (e.g. a private package) does not contain __version__ property, a simple sentry_sdk.init() fails with AttributeError: module 'channels' has no attribute '__version__'

The code in sentry_sdk/integrations/threading.py:59

try:
    from django import VERSION as django_version  # noqa: N811
    import channels  # type: ignore[import-untyped]

    channels_version = channels.__version__  # < raises AttributeError
except ImportError:
    django_version = None
    channels_version = None

Expected Result

sentry_sdk.init() should work regardless of the contents of channels module

Actual Result

import sentry_sdk
sentry_sdk.init()
...
File ~/.../python3.11/site-packages/sentry_sdk/integrations/threading.py:59, in ThreadingIntegration.setup_once()
     56     from django import VERSION as django_version  # noqa: N811
     57     import channels  # type: ignore[import-untyped]
---> 59     channels_version = channels.__version__
     60 except ImportError:
     61     django_version = None

AttributeError: module 'channels' has no attribute '__version__'

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions