エラー内容
Beanstalk へ Djangoのアプリケーションをデプロイしようとしたら、以下のエラーが発生しました。どうやら mysqlclient のインストールが原因のようです。
(requirements.txtにmysqlcilentの記載があります。)
2021/01/26 09:37:34.723109 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt
file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr: ERROR: Command errored out with exit status 1:
command: /var/app/venv/staging-LQM1lest/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-en_mkkv0
cwd: /tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/
Complete output (12 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-nebdennp/mysqlclient_9261c2b2f0fb4076a2579325b6b9c90f/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解決策
.ebextensions/01_packages.config というファイルを作成して以下を記載します。
packages:
yum:
python3-devel: []
mariadb-devel: []
関連
Elastic Beanstalk で python の Django アプリケーションをデプロイする方法
.ebextensionsについては以下を参考にしてください。
設定ファイル (.ebextensions) による高度な環境のカスタマイズ