If you need to execute Python scripts in your Trigger.dev project, you can use theDocumentation Index
Fetch the complete documentation index at: https://trigger-docs-mcp-readonly-runtime-flag.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
pythonExtension build extension via the @trigger.dev/python package.
First, you’ll need to install the @trigger.dev/python package:
pythonExtension build extension in your trigger.config.ts file:
python utilities in the @trigger.dev/python package to execute Python scripts in your tasks. For example, running a Python script inline in a task:
Adding python scripts
You can automatically add python scripts to your project using thescripts option in the pythonExtension function. This will copy the specified scripts to the build directory during the deploy process. For example:
python directory to the build directory during the deploy process. You can then execute these scripts using the python.runScript function:
The pythonExtension will also take care of moving the scripts to the correct location during
dev
mode, so you can use the same exact path in development as you do in production.Using requirements files
If you have arequirements.txt file in your project, you can use the requirementsFile option in the pythonExtension function to install the required packages during the build process. For example:
requirements.txt file during the build process. You can then use these packages in your Python scripts.
The
requirementsFile option is only available in production mode. In development mode, you can
install the required packages manually using the pip command.Virtual environments
If you are using a virtual environment in your project, you can use thedevPythonBinaryPath option in the pythonExtension function to specify the path to the Python binary in the virtual environment. For example:
Streaming output
All of thepython functions have a streaming version that allows you to stream the output of the Python script as it runs. For example:
Environment variables
We automatically inject the environment variables in theprocess.env object when running Python scripts. You can access these environment variables in your Python scripts using the os.environ dictionary. For example:
env option in the python.runScript function. For example:

