Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve error "sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: session" when running Airflow

Tags:

python

airflow

I've installed Apache Airflow version 2.2.4 on my system Ubuntu 20.0.4 LTS and I'm using these steps

  • export AIRFLOW_HOME=~/airflow
  • pip3 install apache-airflow
  • airflow db init
  • airflow users create --username admin --firstname XXXX --lastname XXX --role Admin --email [email protected]

When I'm running my server using this command

  • airflow webserver -p 8080

I've got an error saying

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: session

apacheAirflow

How can I solve this error?

like image 720
iamhimanshu0 Avatar asked Sep 14 '25 12:09

iamhimanshu0


1 Answers

For me the issue was that I have set the AIRFLOW_HOME on one tab of my terminal, but on the other tab (from where I was running the webserver) I forgot to set it. So the solution is to do the following in ALL TERMINAL TABS that you're using for Airflow:

  1. Activate the virtual environment where your Airflow is installed

    source your_airflow_venv/bin/activate
    
  2. Navigate to the directory where your Airflow project is

    cd /path_to_your_airflow_dir
    
  3. Update your AIRFLOW_HOME environment variable

    export AIRFLOW_HOME=$(pwd)
    
  4. Initialize the Airflow database

    airflow db init
    
  5. Start the Airflow Web Server or the Airflow Scheduler (depending on which terminal tab you currently are)

    airflow scheduler
    airflow webserver
    
like image 200
tsveti_iko Avatar answered Sep 17 '25 02:09

tsveti_iko