Loading...
Loading...
ModuleNotFoundError: No module named 'libs' (in Airflow Triggerer process)In Amazon MWAA, the Triggerer process (responsible for Deferrable Operators) runs with a different classpath environment than the Workers. While Workers automatically include the DAGs folder in their Python path, the Triggerer often fails to find custom modules like 'libs' or 'plugins' when task signals are serialized/deserialized.
The most reliable fix is to explicitly add the DAGs folder to the PYTHONPATH via the AWS Console for your MWAA environment.
// AWS Console -> MWAA -> Edit Environment
// Airflow configuration options:
// Key: core.lazy_load_plugins
// Value: False
// Environment variables:
// Key: PYTHONPATH
// Value: /usr/local/airflow/dags:/usr/local/airflow/dags/libsEnsure your custom library folder contains an __init__.py file to be recognized as a valid Python package.
dags/
your_dag.py
libs/
__init__.py
custom_logic.pyIf you cannot modify environment variables, you can force the path into the triggerer's context inside the Trigger class.
import sys
import os
class MyTrigger(BaseTrigger):
def __init__(self, ...):
dags_path = os.environ.get('AIRFLOW_HOME', '/usr/local/airflow') + '/dags'
if dags_path not in sys.path:
sys.path.append(dags_path)