Error while installing mysqlclient with pipenv

this is what my console is saying:
I am on an M1 Mac Mini with the latest MacOS Ventura

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing mysqlclient...
Resolving mysqlclient...
⠦ Installing mysqlclient...[31m[1mError: [0m An error occurred while installing [32mmysqlclient[0m!
Error text: Collecting mysqlclient
  Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata ( started
  Preparing metadata ( finished with status 'error'

[36m  error: subprocess-exited-with-error
  × python egg_info did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      /bin/sh: mysql_config: command not found
      /bin/sh: mariadb_config: command not found
      /bin/sh: mysql_config: command not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/m7/pz85l0hx3pn00v5n75y8src00000gn/T/pip-install-9yuloskm/mysqlclient_cf51d021f9144dcfaf02fede6e5dd224/", line 15, in <module>
          metadata, options = get_config()
        File "/private/var/folders/m7/pz85l0hx3pn00v5n75y8src00000gn/T/pip-install-9yuloskm/mysqlclient_cf51d021f9144dcfaf02fede6e5dd224/", line 70, in get_config
          libs = mysql_config("libs")
        File "/private/var/folders/m7/pz85l0hx3pn00v5n75y8src00000gn/T/pip-install-9yuloskm/mysqlclient_cf51d021f9144dcfaf02fede6e5dd224/", line 31, in mysql_config
          raise OSError("{} not found".format(_mysql_config_path))
      OSError: mysql_config not found
      mysql_config --version
      mariadb_config --version
      mysql_config --libs
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
This is likely caused by a bug in [32mmysqlclient[0m. Report this to its maintainers.
✘ Installation Failed

check my post here:

i am working on ubuntu and needed to install another package (libmysqlclient-dev) first.
afterwards it was resolved.


I am on macOS Monterey v12.6.7. After using brew to install mysqlclient and mysql. All I had to do to fix this issue was use this command:

brew install mysql-client pkg-config