Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

The Python Agent is not enabled



Hello everyone,

I have new relic as an add-on on Heroku, my app’s framework is Flask. I am trying to send custom events on my background jobs so I can chart them on Insights.

Here’s the sample script I am playing around.

import newrelic.agent

def complete_sync():
    app = newrelic.agent.application()
    s = newrelic.agent.record_custom_event('inventory_image', {}, application=app)

Whenever I execute that, I get this error:

2018-11-17T14:12:33.735287+00:00 app[worker.1]: 2018-11-17 14:12:33,735 (28/MainThread) newrelic.core.agent INFO - New Relic Python Agent (

2018-11-17T14:12:33.736981+00:00 app[worker.1]: 2018-11-17 14:12:33,736 (28/MainThread) newrelic.core.agent WARNING - The Python Agent is not enabled.

I also tried running this command :
heroku run newrelic-admin validate-config - stdout

But gave me the following errors.

  File "/app/.heroku/python/bin/newrelic-admin", line 11, in <module>
    load_entry_point('newrelic==', 'console_scripts', 'newrelic-admin')()
  File "/app/.heroku/python/lib/python2.7/site-packages/newrelic/admin/", line 140, in main
  File "/app/.heroku/python/lib/python2.7/site-packages/newrelic/admin/", line 162, in validate_config
    log_file=log_file, log_level=log_level)
  File "/app/.heroku/python/lib/python2.7/site-packages/newrelic/", line 2753, in initialize
    log_file, log_level)
  File "/app/.heroku/python/lib/python2.7/site-packages/newrelic/", line 922, in _load_configuration
    'Unable to open configuration file %s.' % config_file)
newrelic.api.exceptions.ConfigurationError: Unable to open configuration file stdout.

Any idea what’s going on here? I have the license key as an Environment Variable on Heroku and am successfully receiving data on my APM overview page.



I noticed your application is missing a few key components. You will need to initialize and register_application. Below you can find a snippet of code that should work for you. Let me know if this solves your issue!

import newrelic.agent
app = newrelic.agent.register_application(timeout=10.0)

def complete_sync():
    s = newrelic.agent.record_custom_event('inventory_image', {}, application=app)