【问题标题】:Adding Rollbar in a Heroku application without the Rollbar Heroku add-on在没有 Rollbar Heroku 插件的 Heroku 应用程序中添加 Rollbar
【发布时间】:2019-12-13 06:04:49
【问题描述】:

我正在尝试在 Heroku 中将滚动条添加到我的 python 烧瓶应用程序中。

Pipfile

Rollbar = "~=0.14.7"

app.py

import rollbar

rollbar_api_key = os.environ['ROLLBAR_API_KEY']

rollbar.init(rollbar_api_key)
rollbar.report_message('Rollbar is configured correctly')

try:
  b = a + 1
except:
  rollbar.report_exc_info()

但这不起作用。

由于需要信用卡详细信息,我无法在 Heroku 中将滚动条添加为插件。是否可以在没有附加组件的情况下在 heroku 中添加滚动条?

更新:

错误:

app[web.1]: import rollbar
app[web.1]: ModuleNotFoundError: No module named 'rollbar'

链接到我要为其添加Rollbar的应用程序:

https://github.com/glassechidna/fwdform2

【问题讨论】:

  • 这是否意味着您没有任何 Rollbar 帐户?还是不通过 Heroku 插件?
  • @DenisCornehl 我确实有一个 Rollbar 帐户。但我无法设置 Heroku 插件。
  • 您看到什么样的错误?设置 API-Key 后,我假设一切正常。这个 app.py 只做你在这里描述的事情吗?还是它也在运行服务器?许多日志记录/报告库实际上在后台线程中发送错误,所以如果应用程序退出太快,我相信它可能会丢失
  • 我正在 Heroku 中运行一个 python 烧瓶应用程序。我收到此错误:app[web.1]: import rollbar app[web.1]: ModuleNotFoundError: No module named 'rollbar'
  • 链接到我要添加的应用程序Rollbar: github.com/glassechidna/fwdform2

标签: python heroku flask rollbar


【解决方案1】:

由于您看到错误ModuleNotFound,似乎没有安装rollbar python 包。

要将新包添加到项目的Pipfile 和Pipfile.lock,您必须使用pipenv 包:

$ pip install pipenv 
 [...]
$ pipenv install rollbar 

Creating a Pipfile for this project…
Installing rollbar…
Adding rollbar to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success!
Updated Pipfile.lock (0834c3)!

With pipenv you'll need the `pipenv install` command: 
, following for example the [pipenv guide here](https://realpython.com/pipenv-guide/#example-usage). 

正如您在输出中看到的,该命令将同时更新Pipfile 和Pipfile.lock。

【讨论】:

    【解决方案2】:

    您是否设置了 ROLLBAR_​​API_KEY 环境变量的值?当您添加 Rollbar 插件时,它会为您设置,但如果您想在不使用插件的情况下使用 Roller,您需要自己设置。这可以通过heroku config:set ROLLBAR_API_KEY=ABC123 完成。

    【讨论】:

    • 我已经手动配置过了。这不是问题。
    猜你喜欢
    • 2019-09-28
    • 2019-04-24
    • 1970-01-01
    • 2018-06-30
    • 2018-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多