iamhimanshu0
iamhimanshu0

Reputation: 379

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

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

When I'm running my server using this command

I've got an error saying

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

apacheAirflow

How can I solve this error?

Upvotes: 3

Views: 7543

Answers (3)

I had the same error message. I made the mistake and naively installed airflow through pip.

I fixed the issue by deleting the directory AIRFLOW_HOME points to and reinstalling airflow through pip with a constraint. Then I initiated the automated airflow setup with the airflow standalone command.

Upvotes: 0

tsveti_iko
tsveti_iko

Reputation: 7952

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
    

Upvotes: 4

ANURAG BISHT
ANURAG BISHT

Reputation: 21

Before running webserver using command airflow webserver, make sure to set AIRFLOW_HOME using below command:

 export AIRFLOW_HOME="your_airflow_directory"

Upvotes: 0

Related Questions