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
Release: 2024-11-15 10:49:02
Original
354 people have browsed it

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
Copy after login

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
Copy after login
  • Debian/Ubuntu:
sudo apt-get install libmysqlclient-dev
Copy after login
  • Fedora/CentOS:
sudo yum install mysql-devel
Copy after login

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

sudo apt install default-libmysqlclient-dev
Copy after login

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
Copy after login

Add the following line to the file:

/usr/local/mysql/lib
Copy after login

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

sudo ldconfig
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template