[Python] Flask_session error when building containerized version of Airflow using podman

Discussão em 'Python' iniciado por Stack, Maio 28, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to build a container to run my airflow using only dockerfile (not docker-compose). Here is my dockerfile. I'm running this on a server linux machine I succesfully managed to build the image, but when I run, it would not immediately exit and output the error: File "/usr/local/lib/python3.10/site-packages/airflow/www/session.py", line 21, in <module> from flask_session.sessions import SqlAlchemySessionInterface ModuleNotFoundError: No module named 'flask_session.sessions'

    Here is my dockerfile:

    FROM python:3.10.13-slim-bullseye

    # Never prompts the user for choices on installation/configuration of packages
    ENV DEBIAN_FRONTEND noninteractive
    ENV TERM linux

    # Airflow
    ARG AIRFLOW_VERSION=2.7.3
    ARG AIRFLOW_DEPS=""
    ARG PYTHON_DEPS=""
    ENV AIRFLOW_HOME=/usr/local/airflow

    # Define en_US.
    ENV LANGUAGE en_US.UTF-8
    ENV LANG en_US.UTF-8
    ENV LC_ALL en_US.UTF-8
    ENV LC_CTYPE en_US.UTF-8
    ENV LC_MESSAGES en_US.UTF-8
    ENV AIRFLOW__CORE__EXECUTOR LocalExecutor
    RUN set -ex \
    && buildDeps=' \
    freetds-dev \
    libkrb5-dev \
    libsasl2-dev \
    libssl-dev \
    libffi-dev \
    libpq-dev \
    ' \
    && apt-get update -yqq \
    && apt-get upgrade -yqq \
    && apt-get install -yqq --no-install-recommends \
    $buildDeps \
    freetds-bin \
    build-essential \
    default-libmysqlclient-dev \
    unixodbc-dev \
    apt-utils \
    curl \
    rsync \
    netcat \
    locales \
    sudo \
    git \
    krb5-user \
    openssh-client \
    && apt-get install gnupg2 apt-transport-https curl -y \
    && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/11/prod.list > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update \
    && ACCEPT_EULA=Y apt-get install msodbcsql17 -y \
    && ACCEPT_EULA=Y apt-get install mssql-tools -y \
    && echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc \
    && sed -i 's/^# en_US.UTF-8 UTF-8$/en_US.UTF-8 UTF-8/g' /etc/locale.gen \
    && locale-gen \
    && update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 \
    && useradd -ms /bin/bash -d /usr/local/airflow airflow \
    && pip install -U pip setuptools wheel \
    && pip install 'SQLAlchemy==1.3.23' \
    && pip install 'Flask-SQLAlchemy==2.4.4' \
    && pip install pytz \
    && pip install pyOpenSSL \
    && pip install ndg-httpsclient \
    && pip install pyasn1 \
    && pip install openpyxl \
    && pip install pyodbc \
    && pip install pysmb \
    && pip install twilio \
    && pip install oauth2client \
    && pip install googleads \
    && pip install twitter_ads \
    && pip install google-api-python-client \
    && pip install virtualenv \
    && pip install 'werkzeug<1.0.0' \
    && pip install 'email-validator' \
    && pip install "apache-airflow[crypto,celery,hive,jdbc,ssh]==2.7.3" \
    && pip install 'redis==3.2' \
    && pip install facebook_business \
    && if [ -n "${PYTHON_DEPS}" ]; then pip install ${PYTHON_DEPS}; fi \
    && apt-get purge --auto-remove -yqq $buildDeps \
    && apt-get autoremove -yqq --purge \
    && apt-get clean \
    && rm -rf \
    /var/lib/apt/lists/* \
    /tmp/* \
    /var/tmp/* \
    /usr/share/man \
    /usr/share/doc \
    /usr/share/doc-base


    What do you think I should do to tackle this?

    Continue reading...

Compartilhe esta Página