mac 安装mysql client遇到问题
pip3 install mysqlclient Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting mysqlclient Using cached https://pypi.tuna.tsinghua.edu.cn/packages/de/9c/b176826e8994551ce826404dab97e305a4bb76c8b0a4e016fabda2901c71/mysqlclient-2.2.0.tar.gz (89 kB) Installing build dependencies ... done Getting requirements to build wheel ... error ERROR: Command errored out with exit status 1: command: /Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/bin/python /Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/tmpjs1tjc79 cwd: /private/var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/pip-install-7rk3qvdf/mysqlclient_471024006cd3403eb739d20952d3ffbf Complete output (22 lines): 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. Traceback (most recent call last): File "/Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 280, in <module> main() File "/Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 114, in get_requires_for_build_wheel return hook(config_settings) File "/private/var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/pip-build-env-pjpe0jm7/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) File "/private/var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/pip-build-env-pjpe0jm7/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires self.run_setup() File "/private/var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/pip-build-env-pjpe0jm7/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, 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 ---------------------------------------- WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/packages/de/9c/b176826e8994551ce826404dab97e305a4bb76c8b0a4e016fabda2901c71/mysqlclient-2.2.0.tar.gz#sha256=04368445f9c487d8abb7a878e3d23e923e6072c04a6c320f9e0dc8a82efba14e (from https://pypi.tuna.tsinghua.edu.cn/simple/mysqlclient/) (requires-python:>=3.8). Command errored out with exit status 1: /Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/bin/python /Users/gaoxianghu/PycharmProjects/aliyunpanCrawler/venv/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py get_requires_for_build_wheel /var/folders/3k/wmyqxb017sg6ntf3n3cgx1zr0000gn/T/tmpjs1tjc79 Check the logs for full command output. Using cached mysqlclient-2.1.1-cp38-cp38-macosx_10_9_x86_64.whl Installing collected packages: mysqlclient
这时用brew install mysql-client,然后brew info mysql-client,有提示
==> mysql-client: stable 8.1.0 (bottled) [keg-only] Open source relational database management system https://dev.mysql.com/doc/refman/8.0/en/ /usr/local/Cellar/mysql-client/8.1.0 (128 files, 149.6MB) Poured from bottle using the formulae.brew.sh API on 2023-09-03 at 05:14:19 From: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git/Formula/m/mysql-client.rb License: GPL-2.0-only with Universal-FOSS-exception-1.0 ==> Dependencies Build: bison ✘, cmake ✘, pkg-config ✔ Required: libevent ✔, libfido2 ✔, openssl@3 ✔, zlib ✔, zstd ✔ ==> Caveats mysql-client is keg-only, which means it was not symlinked into /usr/local, because it conflicts with mysql (which contains client libraries). If you need to have mysql-client first in your PATH, run: echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc For compilers to find mysql-client you may need to set: export LDFLAGS="-L/usr/local/opt/mysql-client/lib" export CPPFLAGS="-I/usr/local/opt/mysql-client/include" For pkg-config to find mysql-client you may need to set: export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig"
按照提示,运行 export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig" 再 pip install mysqlclient就没问题了
喜欢艺术的码农