pip install mysqlclient でエラー「Getting requirements to build wheel did not run successfully」

  • Macbook Pro
  • Mac OS Sonoma version 14.3.1

エラー「Getting requirements to build wheel did not run successfully」

% pip install mysqlclient
Collecting mysqlclient
  Downloading mysqlclient-2.2.7.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
  ╰─> [30 lines of output]
      /bin/sh: pkg-config: command not found
      /bin/sh: pkg-config: command not found
      /bin/sh: pkg-config: command not found
      /bin/sh: pkg-config: command 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.
      Trying pkg-config --exists libmariadb
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
      Trying pkg-config --exists perconaserverclient
      Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.
      Traceback (most recent call last):
        File "/Users/ユーザー名/PythonProjects/yahoonews_scraper/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/Users/ユーザー名/PythonProjects/yahoonews_scraper/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "/Users/ユーザー名/PythonProjects/yahoonews_scraper/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/private/var/folders/zs/f04s_hhx3s73djbc3h9cvyn40000gn/T/pip-build-env-ost_1kt5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/private/var/folders/zs/f04s_hhx3s73djbc3h9cvyn40000gn/T/pip-build-env-ost_1kt5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 303, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/zs/f04s_hhx3s73djbc3h9cvyn40000gn/T/pip-build-env-ost_1kt5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 319, in run_setup
          exec(code, locals())
        File "<string>", line 156, 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.

note: This error originates from a subprocess, and is likely not a problem with pip.

pkg-config のインストール

% brew install pkg-config
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/services, homebrew/core and homebrew/cask).
==> New Formulae
babelfish       redocly-cli     umka-lang       xlsclients      xwininfo
ludusavi        sdl3            xeyes           xprop
==> New Casks
dana-dex                   font-maple-mono-nf-cn      startupfolder
dockfix                    imaging-edge-webcam        valhalla-freq-echo
flashspace                 linearmouse@beta           valhalla-space-modulator
font-maple-mono-cn         muteme

You have 1 outdated cask installed.

==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/manifests/2.3.0_1-1
######################################################################### 100.0%
==> Fetching pkgconf
==> Downloading https://ghcr.io/v2/homebrew/core/pkgconf/blobs/sha256:fb3a6a6fcb
######################################################################### 100.0%
==> Pouring pkgconf--2.3.0_1.sonoma.bottle.1.tar.gz
🍺  /usr/local/Cellar/pkgconf/2.3.0_1: 27 files, 328.6KB
==> Running `brew cleanup pkgconf`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
% 

「pip install mysqlclient」の再実行

% pip install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.7.tar.gz (91 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (pyproject.toml) ... done
  Created wheel for mysqlclient: filename=mysqlclient-2.2.7-cp38-cp38-macosx_10_9_x86_64.whl size=75920 sha256=dfb71baa06f2124c94179a921f590419fe72775f3da899f8adc1261117cdb701
  Stored in directory: /Users/ユーザー名/Library/Caches/pip/wheels/5b/ed/4f/23fd3001b8c8e25f152c11a3952754ca29b5d5f254b6213056
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-2.2.7
% 

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です