0

I have looked all over the internet including here. I have tried all the suggested solutions, but none of them worked. Here is the error message I get _mysql.c:44:10: fatal error: 'my_config.h' file not found

Could the problem come from the fact that my MySQL and Python versions are not compatible? MySql version:Ver 8.0.21 for osx10.15 on x86_64 (Homebrew) Python version:Python 2.7.16

Could that simply be it? Thanks!

3 Answers 3

3

This solution is for macOS users

After struggling a while on this issue I finally solved it, and it was pretty simple in the end. Maybe this will help others too, because I have seen this issue around a lot during my research. There are plenty of solutions out there, that worked for some and not for others. None of them worked for me.

Before you go into a copy/paste of commands rampage in your terminal, you might want to check your MySQL version. Because apparently MySQL only supports the MySQL-python dependency until version 5.7. So I just had to downgrade my MySQL 8 to 5.7, and then I could finally run the pip install MySQL-python command, and it worked!

So if you have a MySQL version higher than 5.7, you might want to downgrade. To that, type in these commands in your terminal:

brew unlink mysql

brew install [email protected]

Then, try mysql --version If mysql is still red, run this command:

export PATH=${PATH}:/usr/local/mysql/bin

And you should finally be able to run:

pip install MySQL-python

This worked for me, hope it will for you!

Sign up to request clarification or add additional context in comments.

Comments

1

Download whl file from https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python. according to your pc architecture.(win32 or amd64) These are prebuilt binaries.

open cmd to the location of the file. pip install file_name

6 Comments

Thanks a lot, but it says a Python 3 compatible fork of MySQL-python I have python 2.7, will it still work?
Dont download mysqlclient. That is a Python 3 compatible fork of MySQL-python. cp27 in the name means it is compatible with python 2.7
Thanks again for your help. But is I am wondering if these files are just for windows? I am working on a mac, and with both files I get this message: ERROR: MySQL_python-1.2.5-cp27-none-win32.whl is not a supported wheel on this platform
@OlivierGirardot, yes.they are only for windows. win32 in text will help you identify that.For mac you might have to refer this
OK, problem finally solved! It was that MySQL only supports the MySQL-python dependency until version 5.7. So I just had to downgrade my MySQL 8 to 5.7, and then I could finally run the pip install MySQL-python command, and it worked!
|
0

try installing,

pip install pmysql
pip install mysql-connector
pip install mysql-connector-python

all are the same

1 Comment

Thank you Ahmad, but I had already tried that. In the meantime I found the solution which was to downgrade my MySql version (see accepted solution). But thanks a lot anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.