Troubleshooting 'EnvironmentError: mysql_config not found' on Mac OS X
In an attempt to utilize Django on a Google App Engine project, an error arises due to the absence of the MySQLdb module. Despite attempts to install Mysql-python, the installation fails with an "EnvironmentError: mysql_config not found."
Steps have been taken to eliminate other potential causes, such as uninstalling and reinstalling. However, the error persists upon reinstalling using "sudo pip install MySQL-python."
Troubleshooting Approach
Confirm Installation:
Ensure that you have followed these steps in sequence:
a. Python installation
b. "brew install mysql"
c. "export PATH=$PATH:/usr/local/mysql/bin"
d. "pip install MySQL-Python" (or "pip3 install mysqlclient" for Python 3)
Locate 'mysql_config':
Verify the location of 'mysql_config' by running "which mysql_config" in bash. If it returns "not found," use "locate mysql_config" to search for its presence. Adjust your "$PATH" environment variable or manually specify the path to 'mysql_config' in the setup.py file.
Using an Alternative Package:
Consider using 'mysql-connector-python' instead of MySQL-Python. It can be installed via "pip install mysql-connector-python."
Manual File Management:
Manually identify the locations of 'mysql/bin,' 'mysql_config,' and 'MySQL-Python,' then add them to your "$PATH" environment variable.
MacPorts Installation (Optional):
If other methods fail, install 'mysql' using MacPorts. This creates a 'mysql_config5' file instead of 'mysql_config.' Adjust your "$PATH" accordingly: "export PATH=$PATH:/opt/local/lib/mysql5/bin."
Additional Notes:
Resources:
The above is the detailed content of How to Solve 'EnvironmentError: mysql_config not found' When Installing MySQLdb on macOS?. For more information, please follow other related articles on the PHP Chinese website!