Home >Backend Development >Python Tutorial >How to Fix \'EnvironmentError: mysql_config not found\' During MySQL-Python Installation?

How to Fix \'EnvironmentError: mysql_config not found\' During MySQL-Python Installation?

Linda Hamilton
Linda HamiltonOriginal
2024-11-15 10:49:02362browse

How to Fix

Addressing "EnvironmentError: mysql_config not found" during Pip MySQL-Python Installation

When attempting to install the MySQL-python library using pip, you may encounter the following error:

EnvironmentError: mysql_config not found

This error indicates that the installer cannot locate the mysql_config program on your system. To resolve this issue, you need to ensure that mysql_config is installed and accessible by the installer.

  • macOS:
sudo port install mysql-connector-c
  • Debian/Ubuntu:
sudo apt-get install libmysqlclient-dev
  • Fedora/CentOS:
sudo yum install mysql-devel

Note: In newer versions of Ubuntu Debian (as of 2018 ), use the following command instead:

sudo apt install default-libmysqlclient-dev

If you have manually compiled the MySQL suite, the mysql_config may not be in your path. In this case, you can add the path manually by editing the /etc/ld.so.conf file and adding the path to the MySQL libraries.

sudo nano /etc/ld.so.conf

Add the following line to the file:

/usr/local/mysql/lib

Save and close the file, then run the following command:

sudo ldconfig

This should add the MySQL libraries to your path and resolve the mysql_config not found error.

The above is the detailed content of How to Fix \'EnvironmentError: mysql_config not found\' During MySQL-Python Installation?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn