HOME BLOG

How to fix error “my_config.h” file not found in MySQL-python on Mac OS

Posted on: September 30th, 2022 by Olu No Comments

Hi folks,

In this post I will briefly touch on how to fix the error that my_config.h could not be found when trying to install MySQL-python with pip on Mac OS 12.0.x with Python 2.7.x. We assume you installed MySQL via Homebrew.

The error looks like

    _mysql.c:44:10: fatal error: 'my_config.h' file not found
    #include "my_config.h"
             ^~~~~~~~~~~~~
    1 error generated.
    error: command 'clang' failed with exit status 1

 

First, download my_config.h using commands:

cd ~/Downloads
curl https://raw.githubusercontent.com/jacob5412/MySQL-Medium/main/my_config.h -o my_config.h

 

Next, find your MySQL version by running command

mysql --version

Let’s assume your version is 8.0.29.

Make sure the following directory exists /usr/local/Cellar/mysql/8.0.29/include/mysql/.

Then copy the downloaded my_config.h into the directory using command:

cp my_config.h /usr/local/Cellar/mysql/8.0.29/include/mysql/

That’s it. You can now install MySQL-python using command:

pip install MySQL-python

That’s all for now. Till next time, happy software development.

References

Fixing “my_config.h” file not found in MySQL-python (Mac OS). https://medium.com/the-rising-tilde/fixing-my-config-h-file-not-found-in-mysql-python-mac-os-ff97663a8042.

Leave a Reply