I am trying to add rollbar to my python flask application in Heroku.
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()
But this is not working.
I am not able to add rollbar as an addon in Heroku since credit card details are required. Is it possible to add rollbar in heroku without the add-on?
Update:
Error:
app[web.1]: import rollbar
app[web.1]: ModuleNotFoundError: No module named 'rollbar'
Link to the app for which I am trying to add Rollbar
:
Since you are seeing the error ModuleNotFound
, it seems like the rollbar
python package is not installed.
To add a new package to the project's Pipfile
and Pipfile.lock
you have to use the pipenv
package:
$ 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).
As you see in the output the command will update both Pipfile
and Pipfile.lock
.