6

I am currently trying to get Sentry to work with my Django project. While initializing Sentry in the settings.py file I get this error:

line 301, in module import sentry_sdk ModuleNotFoundError: No module named 'sentry_sdk' unable to load app 0 (mountpoint='') (callable not found or import error)

I copied the docs, and I'm wondering why this is happening. Has anyone experienced this issue before? My Django version is 2.2.11 and I'm running python v 3.9.5

Here is the code for the docs if it matters (pip install --upgrade sentry-sdk)

import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    integrations=[DjangoIntegration()],

    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for performance monitoring.
    # We recommend adjusting this value in production,
    traces_sample_rate=1.0,

    # If you wish to associate users to errors (assuming you are using
    # django.contrib.auth) you may enable sending PII data.
    send_default_pii=True,

    # By default the SDK will try to use the SENTRY_RELEASE
    # environment variable, or infer a git commit
    # SHA as release, however you may want to set
    # something more human-readable.
    # release="myapp@1.0.0",
)

2 Answers2

3

Are you sure you have installed sentry in your environment? Ensure you ran pip install sentry-sdk in the same environment you are running your code from

Mark Rofail
  • 808
  • 1
  • 8
  • 18
1

I had to include sentry-sdk==1.1.0 in my requirements file to get it to run.

  • This may work if you use docker, since the requirements file is used by docker to create the image. You may also need to delete/rebuild your image after you add this. – DZet Dec 06 '21 at 04:12