I face this problem when I want to install mysql-python on osx 10.8, it show error with \'my_config.h\' file not found.
Below is my running code:
sud
I tried all the way from answers,that does't work for me.
Just download mysql from
https://dev.mysql.com/downloads/mysql/
and install in your mac. do not use brew install mysql
install MySQL-python
pip install MySQL-python
every thing done
Using conda
instead of pip
solved this for me on macOS Catalina 10.15.5
conda install mysql-python
brew install mysql
brew unlink mysql
brew install mysql-connector-c
sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config
pip install MySQL-python
brew unlink mysql-connector-c
brew link --overwrite mysql
On macOS 10.15 so long as your project is compatible with PyMySQL 1.3.11 or newer, the following appears to resolve this problem:
brew install mariadb-connector-c
pip install MySQL-python
Ref: https://github.com/PyMySQL/mysqlclient-python/blob/master/HISTORY.rst
My problem was that I was using MAMP's version of mysql and it didn't contain the dev headers. I downloaded the dmg of the official release and had it running in no time.
I checked the include
folders for both mysql
and mysql-connector-c
installed by homebrew and was surprised to see there is NO file named my_config.h
. Thus, I think existing high-voted answers can no longer solve the problem.
Here is my solution for mysql 8.0.19
. I copied the mysql.h
file under the include/
folder of my installed mysql-connector-c
and saved it as my_config.h
under the same folder. Then I followed the high-voted solution as below and successfully installed mysql-python 1.2.5
.
brew install mysql
brew unlink mysql
brew install mysql-connector-c # modify the include/ folder after installing the package
sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/Cellar/mysql/8.0.19/bin/mysql_config
pip install MySQL-python
brew unlink mysql-connector-c
brew link --overwrite mysql
At present, I only know it can successfully install the package, but I am not sure whether it is a safe solution.
Actually, mysql-python
is a quite old package (the latest release is 6 years ago), I recommend other packages for interacting with mysql in python (e.g. mysql-connector-python
).