본문 바로가기
공부/프로그래밍

[airflow] mysql 연동으로 수행할때 에러 (Reason: image not found)

by demonic_ 2021. 6. 19.
반응형

에러메세지

$ airflow initdb


Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/bin/airflow", line 25, in <module>
    from airflow.configuration import conf
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/airflow/__init__.py", line 47, in <module>
    settings.initialize()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/airflow/settings.py", line 405, in initialize
    configure_orm()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/airflow/settings.py", line 294, in configure_orm
    engine = create_engine(SQL_ALCHEMY_CONN, connect_args=connect_args, **engine_args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sqlalchemy/engine/__init__.py", line 525, in create_engine
    return strategy.create(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
    return __import__("MySQLdb")
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <module>
    import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_mysql.cpython-38-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/_mysql.cpython-38-darwin.so
  Reason: image not found

 

Mysql의 이미지 위치를 찾지 못해 난 에러.

다음 환경설정을 추가한다.

 

다음 경로에 mysql 이 설치되어 있는지 확인

$ cd /usr/local/mysql/lib

$ ls
libcrypto.1.1.dylib		libmysqlclient.a		libprotobuf-lite.3.11.4.dylib	libprotobuf.dylib		mecab
libcrypto.dylib			libmysqlclient.dylib		libprotobuf-lite.dylib		libssl.1.1.dylib		pkgconfig
libmysqlclient.21.dylib		libmysqlservices.a		libprotobuf.3.11.4.dylib	libssl.dylib			plugin

 

위 경로를 환경변수에 등록

(.zshrc, .bash_profile, .bashrc 등에 등록)

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

다시 수행

$ airflow initdb

 

 

끝.

반응형

댓글