airflow config with OSX

Target are listed below:

  • install airflow
  • setup database with mysql & install provider with mysql

install airflow on OSX

Follow the link to see the details of how to install airflow with constraints file.


# Extract the version of Python you have installed. If you're currently using Python 3.11 you may want to set this manually as noted above, Python 3.11 is not yet supported.
PYTHON_VERSION="$(python --version | cut -d " " -f 2 | cut -d "." -f 1-2)"

# For example this would install 2.6.2 with python 3.7:

pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"

Please consider the command which will install 2.6.2 on python 3.10

pip install "apache-airflow==2.6.2" --constraint ""

Run Airflow standalone:

airflow standalone
Run Airflow with seperate service:

airflow db init

airflow users create \
    --username admin \
    --firstname Peter \
    --lastname Parker \
    --role Admin \

airflow webserver --port 8080

airflow scheduler

Change the airflow working database to mysql:

Install mysql connector:

pip install mysql-connector-python

Create airflow database on mysql:

CREATE DATABASE airflow_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 

Edit the connection string in airflow.cfg:

sql_alchemy_conn = mysql+mysqlconnector://<user>:<password>@<host>[:<port>]/<dbname>

install apache-airflow-providers-mysql on OSX

simply use PyPI to install the apache-airflow-providers-mysql on MAC OSX may not succeed due to the mysql client package missing.

pip install apache-airflow-providers-mysql

Check on PyPI site, ‘apache-airflow-providers-mysql’ should have 3 depended packages:

PIP packageVersion required

While ‘mysqlclient’ on OSX may need a customized installation. On OSX, we should install the server or client for mysql with brew, before install the mysqlclient with PyPI tool.

nstall MySQL and mysqlclient:

# Assume you are activating Python 3 venv
$ brew install mysql pkg-config
$ pip install mysqlclient

If you don’t want to install MySQL server, you can use mysql-client instead:

# Assume you are activating Python 3 venv
$ brew install mysql-client pkg-config
$ export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"
$ pip install mysqlclient

Then install the ‘apache-airflow-providers-mysql’ with PyPI will pass.