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!

Olivier Girardot
  • 389
  • 4
  • 16

3 Answers3

2

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 mysql@5.7

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!

Olivier Girardot
  • 389
  • 4
  • 16
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

Yash
  • 1,271
  • 1
  • 7
  • 9
  • Thanks a lot, but it says ```a Python 3 compatible fork of MySQL-python``` I have python 2.7, will it still work? – Olivier Girardot Sep 21 '20 at 11:05
  • 1
    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 – Yash Sep 21 '20 at 11:06
  • 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``` – Olivier Girardot Sep 21 '20 at 11:21
  • 1
    @OlivierGirardot, yes.they are only for windows. win32 in text will help you identify that.For mac you might have to refer [this](https://stackoverflow.com/questions/51123044/pip-install-mysql-python) – Yash Sep 21 '20 at 11:26
  • Yes of course, but I tried it anyway, I am that desperate lol I also followed the instructions from the link you posted, no luck either. Then I stumbled across another reply, saying that the issue could very well be coming from the MySQL version that no longer supports MySQL-Python – Olivier Girardot Sep 21 '20 at 12:41
  • 1
    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! – Olivier Girardot Sep 21 '20 at 14:18
0

try installing,

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

all are the same

Ahmad Waqar
  • 474
  • 4
  • 7
  • 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! – Olivier Girardot Oct 01 '20 at 12:31