Can't load plugin: sqlalchemy.dialects:mysqldb

Viewed 31

Apache Airflow Docker : sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:mysqldb

version: '3'
x-airflow-common:
  &airflow-common
  image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.3.3}
  # build: .
  environment:
    &airflow-common-env
    AIRFLOW__CORE__EXECUTOR: CeleryExecutor
    AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: mysql+mysqldb://xxx:xxx@xxxxx:xxxx/airflow
    # For backward compatibility, with Airflow <2.3
    AIRFLOW__CORE__SQL_ALCHEMY_CONN: mysql+mysqldb://root:xxxx@xxxxxx:xxxxx/airflow
    AIRFLOW__CELERY__RESULT_BACKEND: db+mysqldb://root:xxxxxx@xxxxxx:xxxxxx/airflow
    AIRFLOW__CELERY__BROKER_URL: redis://:@xxxxxx:6379/0
    AIRFLOW__CORE__FERNET_KEY: ''
    AIRFLOW__CORE__DAGS_ARE_PAUSED_AT_CREATION: 'true'
    AIRFLOW__CORE__LOAD_EXAMPLES: 'true'
    AIRFLOW__API__AUTH_BACKENDS: 'airflow.api.auth.backend.basic_auth'
    _PIP_ADDITIONAL_REQUIREMENTS: ${_PIP_ADDITIONAL_REQUIREMENTS:-}
  volumes:
    - airflow:/opt/airflow/dags
    - ./logs:/opt/airflow/logs
    - ./plugins:/opt/airflow/plugins
  user: "${AIRFLOW_UID:-50000}:0"

I have the same problem,How should this problem be solved.

1 Answers

I think that the problem is with the celery result backend, where celery uses databases drivers different from airflow drivers, you can try:

AIRFLOW__CELERY__RESULT_BACKEND: db+mysql://root:xxxxxx@xxxxxx:xxxxxx/airflow

Here is the celery configuration doc.

Related