While attempting to install the mysql-python package using pip, you may encounter the following error:
EnvironmentError: mysql_config not found
This error indicates that the mysql_config utility, which is required for building the mysql-python package, is not present on your system.
Resolution:
There are a few possible solutions to this issue:
1. Install the MySQL development package
On Debian-based systems, including Ubuntu, you can install the necessary package with the following command:
sudo apt-get install libmysqlclient-dev
For more recent versions of Debian/Ubuntu, use:
sudo apt install default-libmysqlclient-dev
2. Add mysql_config to the PATH environment variable
If mysql_config is installed but not in your PATH, you need to add its directory to the PATH variable. The location of mysql_config varies depending on your system; you can find it using the following command:
which mysql_config
Once you have located the mysql_config utility, add its directory to your PATH by editing the .profile or .bashrc file in your home directory:
export PATH=$PATH:/path/to/mysql_config
3. Compile MySQL from source
If you have the MySQL source code, you can compile it yourself, which will include building the mysql_config utility.
Once you have successfully installed or located mysql_config, you should be able to install the mysql-python package without errors.
The above is the detailed content of Why is pip install mysql-python throwing an \'mysql_config not found\' error?. For more information, please follow other related articles on the PHP Chinese website!