ãmacOSç°å¢ã§mysqlclientã®ã¤ã³ã¹ãã¼ã«ããã¾ããããªããã¨ãã¼ã å ã§ç¸è«ããããèªåã®ç°å¢ã§ããã¾ããããªãã£ãã®ã§è§£æ±ºã¾ã§ã®ã¡ã¢ãæ®ãã¦ããã¾ãã
ç°å¢ã¯ãMac mini 2023 Apple M2, macOS Sonoma 14.6, Python3.12ã§ãã
MySQLã¯ã©ã¤ã¢ã³ãã¨pkg-configã¯Homebrewã§ã¤ã³ã¹ãã¼ã«ãã¾ããã
brew install mysqlclient pkg-config
ãã®ç¶æ ã§ãvenvç°å¢ã§pip installã§requirements.txtããmysqlclientãã¤ã³ã¹ãã¼ã«ããã¨ãããpkg-configã§mysqlclientã®ã©ã¤ãã©ãªãè¦ã¤ããããªãæ¨ã®ã¨ã©ã¼ã¨ãªãã¾ããã
Collecting mysqlclient==2.2.6 (from -r requirements.txt (line 3)) Using cached mysqlclient-2.2.6.tar.gz (91 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 â°â> [29 lines of output] Trying pkg-config --exists mysqlclient Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1. Trying pkg-config --exists mariadb Command 'pkg-config --exists mariadb' returned non-zero exit status 1. Trying pkg-config --exists libmariadb Command 'pkg-config --exists libmariadb' returned non-zero exit status 1. Trying pkg-config --exists perconaserverclient Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 1. Traceback (most recent call last): File "/Users/okano/work/myproject/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/Users/okano/work/myproject/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/okano/work/myproject/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/23/9rdcmsds2d7ff4937xnd7t4h0000gn/T/pip-build-env-xtvhobpp/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=[]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/23/9rdcmsds2d7ff4937xnd7t4h0000gn/T/pip-build-env-xtvhobpp/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires self.run_setup() File "/private/var/folders/23/9rdcmsds2d7ff4937xnd7t4h0000gn/T/pip-build-env-xtvhobpp/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup exec(code, locals()) File "<string>", line 155, in <module> File "<string>", line 49, in get_config_posix File "<string>", line 28, 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.
StackOverflowã«åæ§ã®äºè±¡ã®è³ªåããããåçã«ãã PKG_CONFIG_PATH
ãç°å¢å¤æ°ã«è¨å®ããã解決ãã¾ããã
venvãæå¹ãªç¶æ ã§ãã·ã§ã«ããexportã³ãã³ãã«ã¦ç°å¢å¤æ°ãè¨å®
export PKG_CONFIG_PATH="/opt/homebrew/opt/mysql-client/lib/pkgconfig"
ãã®ç¶æ ã§å度ã¤ã³ã¹ãã¼ã«ãå®æ½ããã¨ãããæåãã¾ããã