2
votes

I am new to airflow and trying to initiate a MySQL db to airflow. I have created a virtual environment and installed the respective packages. I am getting the following error :

airflow initdb

Traceback (most recent call last): File "/Users//Documents/Test/venv/bin/airflow", line 23, in import argcomplete ModuleNotFoundError: No module named 'argcomplete'

I have installed the necessary packages, specifically pip3 install argcomplete which shows the output as :

Requirement already satisfied: argcomplete in ./venv/lib/python3.7/site-packages (1.11.1) Requirement already satisfied: importlib-metadata<2,>=0.23; python_version == "3.7" in /usr/local/lib/python3.7/site-packages (from argcomplete) (1.6.0) Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/site-packages (from importlib-metadata<2,>=0.23; python_version == "3.7"->argcomplete) (3.1.0)

1

1 Answers

1
votes

install the library mysql-conector with pip as follows:

pip3 install mysql-connector 

or,

pip install mysql-connector

Once installed, try running the command to initialize AirflowDB

Update:

Create a user and database in MySQL for Airflow, and pass the user and its password to airflow in its airflow.cfg. Use the following steps for user creation on MySQL db.

CREATE USER 'airfow'@'%' IDENTIFIED BY 'airflow123*'; 

CREATE DATABASE airflowdb; 

GRANT ALL ON airflowdb.* to 'airflow'@'%' IDENTIFIED BY 'airflow123*'; 

FLUSH PRIVILEGES;

Now in your airflow.cfg, pass the username,, password and database name that you have used in the above steps and try to perform the initdb command from the AIRFLOW_HOME directory again.

NOTE: To create a user and database, you have to log into the database as a root user