Preconditions
- You are using MySQL installation from mysql.com (and not e.g. from Macports)
- You want to install MySQL-python egg using easy_install or buildout
You’ll get an error
Getting distribution for 'MySQL-python'. install_dir /Users/moo/project/eggs/tmp8-j13e sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in ? File "/Users/moo/code/collective.buildout.python/python-2.4/lib/python2.4/site-packages/distribute-0.6.14-py2.4.egg/setuptools/command/easy_install.py", line 1855, in main with_ei_usage(lambda: File "/Users/moo/code/collective.buildout.python/python-2.4/lib/python2.4/site-packages/distribute-0.6.14-py2.4.egg/setuptools/command/easy_install.py", line 1836, in with_ei_usage return f() ... 31, in <lambda> {'__file__':setup_script, '__name__':'__main__'} File "setup.py", line 15, in ? File "/var/folders/O8/O8pt7q52F7Oi+P3O0pNqq++++TI/-Tmp-/easy_install-g5cvxl/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config File "/var/folders/O8/O8pt7q52F7Oi+P3O0pNqq++++TI/-Tmp-/easy_install-g5cvxl/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config EnvironmentError: mysql_config not found An error occured when trying to install MySQL-python 1.2.3.Look above this message for any errors thatwere output by easy_install. While: Installing instance. Getting distribution for 'MySQL-python'. Error: Couldn't install: MySQL-python 1.2.3
The reason is that MySQL installer puts MySQL under /usr/local and does not expose MySQL utilites directly to path. MySQL-python expects to find utility mysql_config to configure compile time paths when building native bindings using GCC.
Workaround:
sudo -i cd /usr/bin ln -s /usr/local/mysql-5.1.46-osx10.5-x86_64/bin/mysql_config .
Then rerun installer.
Though it is a bit harsh solution to modify system folder, it gets the thing done in simple manner.
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
Would it be easier to modify your PATH?
Have you tried installing with Homebrew (http://mxcl.github.com/homebrew/)? It will also install MySQL to /usr/local but that’s what that directory is for. Then you can just install pip install MySQL-python.
I just tried this myself and got a bunch of error during the pip install, but I can import _mysql just fine. I haven’t tested beyond that.
Hi,
Thanks for you instructions. Unfortunately I still have no luck with MySQL-python. I have downloaded the latest XCode 3.2, but the MySQL-python installation complains about missing and conflicting files. The first error is about the 10.4 SDK for some reason.
All suggestions would be most appreciated.
Erik
sh-3.2# easy_install MySQL-python
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg –dist-dir /tmp/easy_install-8JoDcG/MySQL-python-1.2.3/egg-dist-tmp-9FK0II
warning: no files found matching ‘MANIFEST’
warning: no files found matching ‘ChangeLog’
warning: no files found matching ‘GPL’
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
from pymemcompat.h:10,
from _mysql.c:29:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from _mysql.c:36:
/usr/local/mysql-5.1.39-osx10.5-x86_64/include/my_config.h:1046:1: warning: “HAVE_WCSCOLL” redefined
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
from pymemcompat.h:10,
from _mysql.c:29:
/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:799:1: warning: this is the location of the previous definition
error: Setup script exited with error: command ‘gcc’ failed with exit status 1
sh-3.2# cd /Developer/SDKs/
sh-3.2# ls
MacOSX10.4u.sdk MacOSX10.5.sdk MacOSX10.6.sdk
sh-3.2#
I run 10.6.6 on
Model Name: MacBook Pro
Model Identifier: MacBookPro3,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.2 GHz
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory <--- looks like it is trying to include files from older SDK revision
From what I understand, from this thread
http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/
the trick is amongst other things to downgrade to 32-bit MySQL and force python to run in 32-bit. Other ideas would be most welcome because this seems a bit dumb. Surely this must be a common issue? However, “Google was not much of a friend” in this case.
Pingback: MySQL-python (aka MySQLdb) on OSX Lion | Active Intelligence