Adam
Adam

Reputation: 483

Getting import _mysql error when initialising Airflow db

I am trying to initialise Airflow mysql database and get the following error.

ImportError: 
1): dlopen(...venv/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 
2): Symbol not found: _mysql_real_escape_string_quote
      Referenced from: ...venv/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so
      Expected in: /usr/local/lib/libmysqlclient.18.dylib
      in...venv/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so

The connection string settings in airflow.cfg:

sql_alchemy_conn = mysql://airflow:airflow@localhost:3306/airflow

Running following airflow, mysql client libraries:

python==3.6
apache-airflow[kubernetes, statsd, crypto]==1.10.5
mysqlclient==1.3.12

Upvotes: 2

Views: 419

Answers (1)

Alexandr Shurigin
Alexandr Shurigin

Reputation: 3981

The bug you see is because Python's mysql used library uses wrong Mac OS library path or version or etc. That happens when Python libs are out of sync with the system libraries (in case of python binary packages like mysql client).

Looks like you have upgraded local Mac OS MySql installation or libraries or you've just moved the python virtual environment folder from another system or computer. To fix the trouble just do pip freeze to get the currently installed libraries in the virtual env, destroy the env folder and reinstall everything using the list dumped. It should work.

Good luck and let me know if it doesn't work.

Upvotes: 1

Related Questions