何の話か & 結論
- docker-compose & pipenv で開発しているアプリが、突然立ち上がらなくなった
- 原因は、2023-06-22にリリースされた
mysqlclient v2.2.0
のインストールに失敗すること - 解決策は
Pipfile
で1つ古いバージョンのmysqlclient
を指定すること
Pipfile
mysqlclient = "==2.1.0"
初期調査で分かったこと
-
docker-compose up
のログを見ているとPipfile
からライブラリ等をインストールしている箇所でエラーが起きる - エラーの内容は
An error occurred while installing xxx ! Will try again.
であまり情報がない
詳細調査
- Pipfileで指定したライブラリを1つ1つインストールして、エラーが起きないか確かめた
- バージョン指定していなかったmysqlclientのインストールでエラーが起きた(以下、エラーログ参照)
$ pipenv run pip install mysqlclient
Loading .env environment variables...
Creating a virtualenv for this project...
Pipfile: /home/xxx/xxx/xxx/Pipfile
Using default python from /usr/bin/python3 (3.8.10) to create virtualenv...
⠏ Creating virtual environment...created virtual environment CPython3.8.10.final.0-64 in 473ms
creator CPython3Posix(dest=/home/ubuntu/.local/share/virtualenvs/xxx--rJLLDQJ, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv)
added seed packages: pip==23.1.2, setuptools==67.8.0, wheel==0.40.0
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
✔ Successfully created virtual environment!
Virtualenv location: /home/ubuntu/.local/share/virtualenvs/xxx--rJLLDQJ
Creating a Pipfile for this project...
Collecting mysqlclient
Using cached mysqlclient-2.2.0.tar.gz (89 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
Traceback (most recent call last):
File "/home/xxx/.local/share/virtualenvs/xxx--rJLLDQJ/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/xxx/.local/share/virtualenvs/xxx--rJLLDQJ/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/xxx/.local/share/virtualenvs/xxx--rJLLDQJ/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-vu4r17k4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-vu4r17k4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-vu4r17k4/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 154, in <module>
File "<string>", line 48, in get_config_posix
File "<string>", line 27, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
追加調査
解決策
-
mysqlclient
のバージョンを落としてインストール - (当たり前の話かもしれませんが、
Pipfile
でバージョンを指定しておくの大事ですね)
Pipfile
mysqlclient = "==2.1.0"
この投稿が誰かのためになればと思い、共有します。