Error When installing mysqlclient

Python Version == 3.10.5

This is the error I’m getting.

Installing mysqlclient…
Error: An error occurred while installing mysqlclient!
Error text: Collecting mysqlclient
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata ( started
Preparing metadata ( finished with status ‘error’

error: subprocess-exited-with-error

× python egg_info did not run successfully.
│ exit code: 1
╰─> [16 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 “”, line 2, in
File “”, line 34, in
File “/private/var/folders/9d/_sspqdqx72j3xbj_00_4tnnc0000gn/T/pip-install-7p4nuy3n/mysqlclient_6a8def8547594e6581afcc9bbc2b1f30/”, line 15, in
metadata, options = get_config()
File “/private/var/folders/9d/_sspqdqx72j3xbj_00_4tnnc0000gn/T/pip-install-7p4nuy3n/mysqlclient_6a8def8547594e6581afcc9bbc2b1f30/”, line 70, in get_config
libs = mysql_config(“libs”)
File “/private/var/folders/9d/_sspqdqx72j3xbj_00_4tnnc0000gn/T/pip-install-7p4nuy3n/mysqlclient_6a8def8547594e6581afcc9bbc2b1f30/”, 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
[end of output]

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 mysqlclient. Report this to its maintainers.
✘ Installation Failed

I had basically the same issue in Ubuntu, and found I needed to install the “python3-dev default-libmysqlclient-dev build-essential” despite already having installed MySQL previously and verifying it worked in my VS Code terminal.

I ran

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

and then was able to successfully install mysql client in my virtual environment! Please see what you need to run for your OS.

Reference: Command errored out with exit status 1: python egg_info Check the logs for full command output while installing mysqlclient - Stack Overflow

Thanks Ill take a look .