7

I am new to Mac and i am trying to install MySQLdb for Python on MAC but after following the steps mentioned on http://www.tutorialspoint.com/python/python_database_access.htm, i received an error after running

$ python setup.py build

Error:

clang: warning: argument unused during compilation: '-mno-fused-madd'
_mysql.c:44:10: fatal error: 'my_config.h' file not found
#include "my_config.h"
     ^
1 error generated.
error: command 'cc' failed with exit status 1

Note: My "mysql_config" path is /Applications/MAMP/Library/bin/mysql_config What should i do?

Osama Yawar
  • 361
  • 2
  • 6
  • 19
  • have you checked out this post? http://stackoverflow.com/questions/15505840/how-to-install-mysql-python-1-2-3-on-mac-os-10-8 – Anthony Kong Feb 08 '14 at 00:36
  • Yes and i already have XAMPP and XAMPP have MySQL - Now i want to resolve this issue using the existing MySQL in XAMPP – Osama Yawar Feb 08 '14 at 20:05

3 Answers3

9

The problem is unused arguments passed to compiler. Try this before running your build code:

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
ABros
  • 479
  • 3
  • 16
2

Try setting this on the terminal before executing:

export CC='/usr/bin/gcc'
export CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I/opt/X11/include -arch i386 -arch x86_64'
export LDFLAGS='-arch i386 -arch x86_64'
export ARCHFLAGS='-arch i386 -arch x86_64'

found it here: https://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion

Walucas
  • 2,549
  • 1
  • 21
  • 44
  • For OSX El Capitan: Use above with below CFLAGS: export CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include -arch i386 -arch x86_64' – Isanka Wijerathne Jul 04 '16 at 10:20
0

I had the same problem today, and I had to downgrade the MySQL 8 to 5.7 to install the Python module.

This procedure worked for me:

brew remove mysql mysql-client mysql-connector-c
brew install mysql@5.7
brew link --force mysql@5.7
pip install mysql-python

I read a post and adjusted the procedure to link things in the /usr/local/bin instead of adding a new route to the PATH variable. Reference: MacOS: "pip install MySQL-python" returning an error: "_mysql.c:44:10: fatal error: 'my_config.h' file not found"