Installing Airbrake in a Python application
- Simple to install and configure
- Integrates with your existing logger
- Add extra context to errors before they are sent
- Set error severity and control notification thresholds
What version of Python are you using?
The version of Python your app is using determines which installation instructions to follow.
The pybrake notifier supports Python 3.4 and above.
pip install -U pybrake
You must set both
To find your
project_key navigate to your project’s
Settings and copy the values from the right sidebar.
import pybrake notifier = pybrake.Notifier(project_id=123, project_key='FIXME', environment='production')
Sending errors to Airbrake
try: raise ValueError('hello') except Exception as err: notifier.notify(err)
Taking pybrake further
Now that pybrake is configured and ready to go we recommend you check out some of the additional integrations and features pybrake supports:
- integrate with the logging standard library
- integrating with Django via Airbrake middleware
- integrating with Flask via the blinker library
- add custom information to notices before they are sent
- define custom filters to ignore notices by type or any other criteria
Visit the pybrake GitHub repo for full details.
Or, you can manually instantiate your
AirbrakeHandler by passing your
PROJECT ID and
PROJECT API KEY as arguments to the
import airbrake logger = airbrake.getLogger(api_key="<Your project API KEY>", project_id=<Your project ID>) try: 1/0 except Exception: logger.exception("Bad math.")
Taking airbrake-python further
Now that you have configured Airbrake to report exceptions from your Python 2.7 app, we recommend you add extra context to your errors and add Airbrake to your existing logger. Please visit the airbrake-python GitHub repo for the full list of notifier features.