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.


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:

         import lightrun
         lightrun.enable(com_lightrun_server="<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

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=<COMPANY-NAME> --com_lightrun_secret=<COMAPNY-SECRET> --

Last update: September 27, 2021