pip install mysql-python fails with EnvironmentError: mysql_config not found

This error occurs when the mysql-config command is not in the system's PATH. One way to fix this is to specify the path to the mysql_config command by setting the environment variable "MYSQL_CONFIG" before running the pip command. Here is an example:

import os
os.environ['MYSQL_CONFIG'] = '/usr/local/mysql/bin/mysql_config'
!pip install mysql-python

Watch a course Python - The Practical Guide

Note: 1- This is a code snippet for python, 2- You need to replace the path of mysql_config command with the path of your mysql-config command in your system. 3- Also you may need to use ! at the start of pip command to run it as shell command if you are running the code snippet in Jupyter notebook or similar environment.