{"id":9813,"library":"honeybadger","title":"Honeybadger Python","description":"Honeybadger Python is the official client library for sending Python and Django errors to Honeybadger.io. It provides real-time error tracking, uptime monitoring, and performance insights for applications built with frameworks like Django, Flask, and Celery, as well as general Python applications and AWS Lambda functions. The library is actively maintained, with version 1.2.2 being the latest, and receives frequent updates including bug fixes and minor features.","status":"active","version":"1.2.2","language":"en","source_language":"en","source_url":"https://github.com/honeybadger-io/honeybadger-python","tags":["error monitoring","exception tracking","django","flask","celery","serverless","aws lambda"],"install":[{"cmd":"pip install honeybadger","lang":"bash","label":"Install core library"},{"cmd":"pip install honeybadger[django]","lang":"bash","label":"Install with Django support"},{"cmd":"pip install honeybadger[flask]","lang":"bash","label":"Install with Flask support"},{"cmd":"pip install honeybadger[celery]","lang":"bash","label":"Install with Celery support"}],"dependencies":[{"reason":"HTTP client for sending data to Honeybadger API","package":"requests","optional":false},{"reason":"Decorator module used for various integrations and patching","package":"wrapt","optional":false},{"reason":"Python 2 and 3 compatibility utilities","package":"six","optional":false},{"reason":"Required for Django framework integration (optional extra)","package":"Django","optional":true},{"reason":"Required for Flask framework integration (optional extra)","package":"Flask","optional":true},{"reason":"Required for Celery integration (optional extra)","package":"celery","optional":true}],"imports":[{"symbol":"honeybadger","correct":"import honeybadger"},{"symbol":"configure","correct":"honeybadger.configure(...)"},{"symbol":"notify","correct":"honeybadger.notify(...)"},{"symbol":"set_context","correct":"honeybadger.set_context(...)"},{"note":"For Flask applications, use the `Honeybadger` class from `contrib.flask`.","symbol":"Honeybadger","correct":"from honeybadger.contrib.flask import Honeybadger"}],"quickstart":{"code":"import honeybadger\nimport os\n\n# Configure Honeybadger using an environment variable or direct assignment\nhoneybadger.configure(api_key=os.environ.get('HONEYBADGER_API_KEY', ''))\n\ndef problematic_function():\n    raise ValueError(\"This is a test error from Honeybadger Python!\")\n\ntry:\n    problematic_function()\nexcept Exception as e:\n    # Manually send the error to Honeybadger\n    honeybadger.notify(e, force_sync=True)\n    print(\"Error notified to Honeybadger. Check your dashboard.\")\n\n# Example of setting custom context\nhoneybadger.set_context(user_id=123, email='test@example.com')","lang":"python","description":"This quickstart demonstrates basic initialization using an API key (preferably from an environment variable) and how to manually send an exception to Honeybadger. For immediate reporting in short-lived scripts, `force_sync=True` is recommended. Remember to replace `HONEYBADGER_API_KEY` with your actual API key from your Honeybadger project settings."},"warnings":[{"fix":"Ensure `honeybadger.configure(api_key='YOUR_API_KEY')` is called, or the `HONEYBADGER_API_KEY` environment variable is set. Errors won't be sent without a valid API key.","message":"Errors not appearing in Honeybadger dashboard due to missing API key configuration.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When calling `honeybadger.notify()`, explicitly set `force_sync=True` (e.g., `honeybadger.notify(exception, force_sync=True)`) to ensure the HTTP request completes before the process exits.","message":"Manual `honeybadger.notify()` calls might not complete in short-lived scripts or serverless functions without `force_sync=True`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For Django, add `'honeybadger.contrib.django'` to `INSTALLED_APPS` and configure it in `settings.py`. For Flask, initialize `Honeybadger` from `honeybadger.contrib.flask` with your Flask app (e.g., `hb = Honeybadger(app=my_flask_app)`).","message":"Automatic error capture for frameworks like Django or Flask requires specific integration setup (middleware/init), not just importing the library.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Update `honeybadger.init(...)` calls to `honeybadger.configure(...)`.","message":"Prior to v1.0, the configuration method was `honeybadger.init()`. This was renamed to `honeybadger.configure()`.","severity":"breaking","affected_versions":"< 1.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Set the `HONEYBADGER_API_KEY` environment variable or explicitly pass `api_key='YOUR_KEY'` to `honeybadger.configure()`.","cause":"The `api_key` was not provided to `honeybadger.configure()` or the `HONEYBADGER_API_KEY` environment variable is missing.","error":"Honeybadger API key is not configured. Errors will not be sent."},{"fix":"Add `force_sync=True` to your `honeybadger.notify()` call: `honeybadger.notify(e, force_sync=True)`.","cause":"Errors are sent asynchronously by default. In fast-exiting scripts (e.g., a CLI tool or serverless function without proper await), the process might terminate before the error report is sent.","error":"No errors appearing in Honeybadger UI, even after `honeybadger.notify()` calls."},{"fix":"Pass configuration options as individual keyword arguments: `honeybadger.configure(api_key='...', environment='production', ...)` instead of `honeybadger.configure(config={'api_key': '...'})`.","cause":"This error can occur if you're trying to pass a dictionary of configuration options as `config` to `honeybadger.configure()`. The `configure` method expects keyword arguments directly.","error":"TypeError: __init__() got an unexpected keyword argument 'config'"}]}