Skip to content

Install the Python Agent

The Lightrun agent is at the core of the Lightrun platform. It's the component that enables us to add information at runtime, without any redeployments or restarts.

Instructions

In order to install the Lightrun Python agent directly please follow these steps:

  1. Install the python agent by running python -m pip install lightrun.

  2. Import Lightrun inside your main function by adding the following code to the beginning of the function:

    try: 
         import lightrun
         lightrun.enable(com_lightrun_server="https://app.lightrun.com/company/<COMPANY_NAME>", com_lightrun_secret="<COMPANY_SECRET>",)
    except ImportError as e:
         print("Error importing Lightrun: ", e)
    
  3. Run the application as you normally would, i.e. python app.py.

Getting Company Details

You can get <COMPANY_NAME> and <COMPANY_SECRET> by logging into the the Management Portal and looking inside the Download the Agent section.

Alternative instructions

You can also pass the <COMAPNY_NAME> and <COMPANY_SECRET> as environment variables:

python -m lightrun --com_lightrun_server=https://app.lightrun.com/company/<COMPANY-NAME> --com_lightrun_secret=<COMAPNY-SECRET> -- app.py

Last update: September 27, 2021