【发布时间】:2021-08-31 15:59:21
【问题描述】:
我目前正在尝试让 Sentry 与我的 Django 项目一起工作。在 settings.py 文件中初始化 Sentry 时出现此错误:
第 301 行,在模块中 导入 sentry_sdk ModuleNotFoundError:没有名为“sentry_sdk”的模块 无法加载应用程序 0 (mountpoint='')(未找到可调用或导入错误)
我复制了文档,但我想知道为什么会这样。有没有人遇到过这个问题?我的 Django 版本是 2.2.11,我正在运行 python v 3.9.5
如果重要的话,这里是文档的代码(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",
)
【问题讨论】: