Bootstrap

macOS 解决 mysql_config 不存在问题

在macOS系统安装python的mysqlclient依赖包时,提示mysql_config不存在,可以通过下面方式解决

1.安装brew,如果已经存在,则跳过该安装

官方文档:macOS(或 Linux)缺失的软件包的管理器 — Homebrew 

打开命令框,输入下面命令进行安装,期间可能需要输入密码进行授权

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

 期间安装需要访问GitHub等国外资源,可能会很慢或者安装失败,多次重试或者科学上网即可

安装之后,需要执行下面命令进行操作

brew tap homebrew/core

安装mysql-connector-c

brew install mysql-connector-c

最后在执行

echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

确保上面的执行都要成功,然后就可以通过pip安装mysqlclient了

安装日志

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R isummer:admin /usr/local/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 21 (delta 8), reused 14 (delta 7), pack-reused 0
Unpacking objects: 100% (21/21), 13.43 KiB | 280.00 KiB/s, done.
From https://github.com/Homebrew/brew
   e62a83900..fec24f5c0  master     -> origin/master
Updating files: 100% (2752/2752), done.
HEAD is now at fec24f5c0 Merge pull request #15352 from woodruffw-forks/ww/step-summary-var
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/isummer/.zprofile
    eval "$(/usr/local/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
% brew tap homebrew/core
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1478291, done.
remote: Counting objects: 100% (270088/270088), done.
remote: Compressing objects: 100% (993/993), done.
remote: Total 1478291 (delta 269250), reused 269374 (delta 269095), pack-reused 1208203
Receiving objects: 100% (1478291/1478291), 349.29 MiB | 16.37 MiB/s, done.
Resolving deltas: 100% (1052169/1052169), done.
Updating files: 100% (6996/6996), done.
Tapped 2 commands and 6645 formulae (7,007 files, 405.7MB).
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
% brew install mysql-connector-c          
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
Warning: Use mysql-client instead of deprecated mysql-connector-c
Warning: Use mysql-client instead of deprecated mysql-connector-c
==> Downloading https://formulae.brew.sh/api/cask.jws.json
#############################                                              40.4%curl: (28) Operation too slow. Less than 100 bytes/sec transferred the last 5 seconds

Warning: cask.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/cask.jws.json
                                                                            0.4%curl: (28) Operation too slow. Less than 100 bytes/sec transferred the last 5 seconds

Warning: cask.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/cask.jws.json
###################                                                        27.2%^C
isummer@isummerdeMacBook-Pro Desktop % brew install mysql-connector-c
Warning: Use mysql-client instead of deprecated mysql-connector-c
Warning: Use mysql-client instead of deprecated mysql-connector-c
==> Downloading https://formulae.brew.sh/api/cask.jws.json
#########                                                                  12.8%curl: (28) Operation too slow. Less than 100 bytes/sec transferred the last 5 seconds

Warning: cask.jws.json: update failed, falling back to cached version.
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Fetching dependencies for mysql-client: ca-certificates, [email protected], libevent, libcbor, libfido2, zlib, lz4, xz and zstd
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/927414ed081d996b84d938be6af4d2639403b4d2bee3cc29268d0844999da180--ca-certificates-2023-01-10.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:11
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/ca2448928ab98c455b5e46d4a6604247a151ab0f4e60553dbb5c6aecd2e1df3c--ca-certificates--2023-01-10.all.bottle.tar.gz
==> Fetching [email protected]
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1t
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/e8519d4f6d202ef928d8abd8368bb1599920846dd8c5d4986fdb9df9497c393f--openssl@1.1-1.1.1t.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:43c008
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/cab5be75b581482c6216d9a371e08c7ce28b28b3df886dddd4ac3a075ba06283--openssl@1.1--1.1.1t.monterey.bottle.tar.gz
==> Fetching libevent
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/manifests/2.1.12
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/3c922e544a2503896bff89f9c72cda549a57375a38f86b02eff00c1ca31c7754--libevent-2.1.12.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/blobs/sha256:b08b593fd
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/f5743d731fa6b4ec0281fc3e36ef8a081b72f72236e58c9b2880011ae0dda253--libevent--2.1.12.monterey.bottle.tar.gz
==> Fetching libcbor
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/manifests/0.10.2
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/b3b69aa10b9eff19299a02bde62661644cfd29b742e5e5bb197e70c03b8f4d96--libcbor-0.10.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/blobs/sha256:5b1cc91f67
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/99443d3995c413a5c10128ca7377833fd1361f997605fa2455434991e5a950e9--libcbor--0.10.2.monterey.bottle.tar.gz
==> Fetching libfido2
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/manifests/1.13.0
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/8e886007165d495c25fd8c18867cd34ef3782d0357b2778fccd7e0776323e169--libfido2-1.13.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/blobs/sha256:cf58469b1
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/aca8a924327715ce9e2f6f49610d95bf452006a72b81c55c2f3298b9f9eefd54--libfido2--1.13.0.monterey.bottle.tar.gz
==> Fetching zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.13-1
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/a885b49d26afa77d3c6b3b7fcc61895ac1148e45d2f61d6e8ee55f53931ecb82--zlib-1.2.13-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:ceee8b2e24b0c
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/987355b089c1f1e55a1f9ef2164d153cf57346b03b26a5ee36275bda9225acdc--zlib--1.2.13.monterey.bottle.1.tar.gz
==> Fetching lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/379e59b981667f9585b33a2ff318769d8edca3ce6fd2e9a67ed291ae3e0cc872--lz4-1.9.4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:88b369cea90a0a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################### 100.0%
==> Fetching xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.2
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:e374ae9bec525b5
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################### 100.0%
==> Fetching zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.5
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:9c1cfe9158a48
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################### 100.0%
==> Fetching mysql-client
==> Downloading https://ghcr.io/v2/homebrew/core/mysql-client/manifests/8.0.32
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/mysql-client/blobs/sha256:f5975
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
###                                                                         4.7%curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)

Error: mysql-client: Failed to download resource "mysql-client"
Download failed: https://ghcr.io/v2/homebrew/core/mysql-client/blobs/sha256:f59757d710beb675217579a01893ea58f6b41cc3b6af22367c34520f1683c695
isummer@isummerdeMacBook-Pro Desktop % brew install mysql-connector-c
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
Warning: Use mysql-client instead of deprecated mysql-connector-c
Warning: Use mysql-client instead of deprecated mysql-connector-c
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
==> Fetching dependencies for mysql-client: ca-certificates, [email protected], libevent, libcbor, libfido2, zlib, lz4, xz and zstd
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/927414ed081d996b84d938be6af4d2639403b4d2bee3cc29268d0844999da180--ca-certificates-2023-01-10.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:11
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/ca2448928ab98c455b5e46d4a6604247a151ab0f4e60553dbb5c6aecd2e1df3c--ca-certificates--2023-01-10.all.bottle.tar.gz
==> Fetching [email protected]
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1t
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/e8519d4f6d202ef928d8abd8368bb1599920846dd8c5d4986fdb9df9497c393f--openssl@1.1-1.1.1t.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:43c008
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/cab5be75b581482c6216d9a371e08c7ce28b28b3df886dddd4ac3a075ba06283--openssl@1.1--1.1.1t.monterey.bottle.tar.gz
==> Fetching libevent
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/manifests/2.1.12
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/3c922e544a2503896bff89f9c72cda549a57375a38f86b02eff00c1ca31c7754--libevent-2.1.12.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libevent/blobs/sha256:b08b593fd
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/f5743d731fa6b4ec0281fc3e36ef8a081b72f72236e58c9b2880011ae0dda253--libevent--2.1.12.monterey.bottle.tar.gz
==> Fetching libcbor
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/manifests/0.10.2
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/b3b69aa10b9eff19299a02bde62661644cfd29b742e5e5bb197e70c03b8f4d96--libcbor-0.10.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libcbor/blobs/sha256:5b1cc91f67
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/99443d3995c413a5c10128ca7377833fd1361f997605fa2455434991e5a950e9--libcbor--0.10.2.monterey.bottle.tar.gz
==> Fetching libfido2
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/manifests/1.13.0
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/8e886007165d495c25fd8c18867cd34ef3782d0357b2778fccd7e0776323e169--libfido2-1.13.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libfido2/blobs/sha256:cf58469b1
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/aca8a924327715ce9e2f6f49610d95bf452006a72b81c55c2f3298b9f9eefd54--libfido2--1.13.0.monterey.bottle.tar.gz
==> Fetching zlib
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/manifests/1.2.13-1
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/a885b49d26afa77d3c6b3b7fcc61895ac1148e45d2f61d6e8ee55f53931ecb82--zlib-1.2.13-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/zlib/blobs/sha256:ceee8b2e24b0c
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/987355b089c1f1e55a1f9ef2164d153cf57346b03b26a5ee36275bda9225acdc--zlib--1.2.13.monterey.bottle.1.tar.gz
==> Fetching lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.4
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/379e59b981667f9585b33a2ff318769d8edca3ce6fd2e9a67ed291ae3e0cc872--lz4-1.9.4.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:88b369cea90a0a
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/9b9f9a92e53eb3723f7c20e843da08cf32ecbcf6fdc28d0703af399a8571f85e--lz4--1.9.4.monterey.bottle.tar.gz
==> Fetching xz
==> Downloading https://ghcr.io/v2/homebrew/core/xz/manifests/5.4.2
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/a3e9156f769d3e7b84fa810d0f9f2f3fdf3280dea14e1e46231ce3d3f92d5960--xz-5.4.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/xz/blobs/sha256:e374ae9bec525b5
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/c7e219275ed626757a018704737a756ec12f684dd677621c824be07e3a72e9f6--xz--5.4.2.monterey.bottle.tar.gz
==> Fetching zstd
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/manifests/1.5.5
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/0afc423c03e4ef9c6e5a0a9bd0833be3f24fe4d17390e10342137f0d1b53dbf7--zstd-1.5.5.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/zstd/blobs/sha256:9c1cfe9158a48
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/d9aa2de0a5afe1055ade9acd08f4b5eca786f394a9dd80d8546dba33901c42f6--zstd--1.5.5.monterey.bottle.tar.gz
==> Fetching mysql-client
==> Downloading https://ghcr.io/v2/homebrew/core/mysql-client/manifests/8.0.32
Already downloaded: /Users/isummer/Library/Caches/Homebrew/downloads/ba2cd0d3b7ccdb142d8dc550c13239adf4463094e4564957c3ed4964e9755f0e--mysql-client-8.0.32.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql-client/blobs/sha256:f5975
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################### 100.0%
==> Installing dependencies for mysql-client: ca-certificates, [email protected], libevent, libcbor, libfido2, zlib, lz4, xz and zstd
==> Installing mysql-client dependency: ca-certificates
==> Pouring ca-certificates--2023-01-10.all.bottle.tar.gz
==> Downloading https://formulae.brew.sh/api/formula.jws.json
-=O=-      #    #    #    #                                                    
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/ca-certificates/2023-01-10: 3 files, 216.9KB
==> Installing mysql-client dependency: [email protected]
==> Pouring [email protected]
🍺  /usr/local/Cellar/[email protected]/1.1.1t: 8,101 files, 18.5MB
==> Installing mysql-client dependency: libevent
==> Pouring libevent--2.1.12.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/libevent/2.1.12: 57 files, 2.0MB
==> Installing mysql-client dependency: libcbor
==> Pouring libcbor--0.10.2.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/libcbor/0.10.2: 31 files, 175.4KB
==> Installing mysql-client dependency: libfido2
==> Pouring libfido2--1.13.0.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/libfido2/1.13.0: 547 files, 1.2MB
==> Installing mysql-client dependency: zlib
==> Pouring zlib--1.2.13.monterey.bottle.1.tar.gz
🍺  /usr/local/Cellar/zlib/1.2.13: 13 files, 409KB
==> Installing mysql-client dependency: lz4
==> Pouring lz4--1.9.4.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/lz4/1.9.4: 22 files, 685.2KB
==> Installing mysql-client dependency: xz
==> Pouring xz--5.4.2.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/xz/5.4.2: 162 files, 2.5MB
==> Installing mysql-client dependency: zstd
==> Pouring zstd--1.5.5.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/zstd/1.5.5: 31 files, 2.5MB
==> Installing mysql-client
==> Pouring mysql-client--8.0.32.monterey.bottle.tar.gz
==> 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"
==> Summary
🍺  /usr/local/Cellar/mysql-client/8.0.32: 129 files, 149MB
==> Running `brew cleanup mysql-client`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> mysql-client
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"
isummer@isummerdeMacBook-Pro Desktop % brew install mysql-connector-c
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################### 100.0%
Warning: Use mysql-client instead of deprecated mysql-connector-c
Warning: Use mysql-client instead of deprecated mysql-connector-c
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################### 100.0%
Warning: mysql-client 8.0.32 is already installed and up-to-date.
To reinstall 8.0.32, run:
  brew reinstall mysql-client

 

;