[Django]-MySQLdb install error โ€“ _mysql.c:44:23: error: my_config.h: No such file or directory

4๐Ÿ‘

โœ…

usually when you get these kinds of errors, you are missing development packages โ€“ you need to install the header files as they donโ€™t come with mysqldb.

iโ€™ve not done this on apple personally, but hereโ€™s a link to their article on how to go about such a thing.

http://support.apple.com/kb/ht4006

after youโ€™ve installed the source, mysqldb should be able to compile and install without issues.

51๐Ÿ‘

you can add manually the header file into mysql include directory (download from github repo):

sudo wget https://raw.githubusercontent.com/paulfitz/mysql-connector-c/master/include/my_config.h -O /usr/include/mysql/my_config.h

Retry pip install

sudo pip install MySQL-python

32๐Ÿ‘

If ubuntu : apt-get install mysql-devel
If centos/rhel : yum install mysql-devel
Then install MySQL-python

17๐Ÿ‘

As found here you need to copy my_config.h to /usr/include/mysql, then pip install MySQL-python.

1๐Ÿ‘

i have just get this problem. i tried use the

VCForPython27.msi

to solve it. but it doesnโ€™t work..

i find the answer in the Github: PyMySQL/mysqlclient-python,

NOTE: Wheels for Windows may be not released with source package. You should pin version in your requirements.txt to avoid trying to install newest source package.

so, the answer is that: assign the version of mysqlclient, use pip install mysqlclient==1.x.x insdead of

0๐Ÿ‘

I had a similar issue and fixed it with:

brew install mysql-client
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
pip install MySQL-python

0๐Ÿ‘

Please check these:

1)libmysqlclient-dev is installed

2)my_config.h is in /usr/include/mysql

If not present find it here:

https://dev.mysql.com/doc/dev/mysql-server/8.0.11/my__config_8h_source.html )

0๐Ÿ‘

Install using deb package from https://packages.debian.org/buster/python-mysqldb

Dependencies are apt install libmariadb3 mariadb-common for the above package.

Leave a comment