0

When I run the command: pip3 install mysqlclient or pip install mysqlclient

I get the following error:

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 "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jpxeffqw/mysqlclient_fed1a50532b74bc1aeaab814d12b88df/setup.py", line 15, in <module>
          metadata, options = get_config()
        File "/tmp/pip-install-jpxeffqw/mysqlclient_fed1a50532b74bc1aeaab814d12b88df/setup_posix.py", line 70, in get_config
          libs = mysql_config("libs")
        File "/tmp/pip-install-jpxeffqw/mysqlclient_fed1a50532b74bc1aeaab814d12b88df/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.

The package is broken I guess but I need to run this now to make it work with my Django project. Any suggestions on any alternates or other command I could run to get the same result?

1

1 Answer 1

1

Windows

As mysqlclient document mentions Building mysqlclient on Windows is very hard. But there are some binary wheels you can install easily.

download the MariaDB C Connector and install it. It must be installed in the default location (usually "C:\Program Files\MariaDB\MariaDB Connector C" or "C:\Program Files (x86)\MariaDB\MariaDB Connector C" for 32-bit). If you build the connector yourself or install it in a different location, set the environment variable MYSQLCLIENT_CONNECTOR before installing.

Linux

You may need to install the Python 3 and MySQL development headers and libraries like so

# Debian / Ubuntu
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

or

# Red Hat / CentOS
sudo yum install python3-devel mysql-devel

you can find more details on the package documentation

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.