PyMySQL/mysqlclient

Can't install mysqlclient on ubuntu for wsl

Enmanuel180 opened this issue · 3 comments

This is the output when I try pip install mysqlclient I also tried with pipenv:
$ pip install mysqlclient
Defaulting to user installation because normal site-packages is not writeable
Collecting mysqlclient
Using cached mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "", line 2, in
File "", line 34, in
File "/tmp/pip-install-9prpmm3m/mysqlclient_97a94e6c3b5142b48d4e2b603ed77ce0/setup.py", line 15, in
metadata, options = get_config()
File "/tmp/pip-install-9prpmm3m/mysqlclient_97a94e6c3b5142b48d4e2b603ed77ce0/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-9prpmm3m/mysqlclient_97a94e6c3b5142b48d4e2b603ed77ce0/setup_posix.py", 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.

Never mind. Chatgpt solved it for me!

Do you can give us the solution? please.

sudo apt-get update
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
pip install mysqlclient