Install mysql-Python under MAC, download source code in: http://sourceforge.net/projects/mysql-python/files? Source = navbar
Decompress the package and run Python setup. py build.
The following error is reported:
SH: mysql_config: Command not found
Traceback (most recent call last ):
File "setup. py", line 18, in <module>
Metadata, Options = get_config ()
File "/users/dongquan/downloads/MySQL-python-1.2.4b4/setup_posix.py", line 43, in get_config
Libs = mysql_config ("libs_r ")
File "/users/dongquan/downloads/MySQL-python-1.2.4b4/setup_posix.py", line 25, in mysql_config
Raise environmenterror ("% s not found" % (mysql_config.path ,))
Environmenterror: mysql_config not found
The solution is to modify site. cfg,
Add mysql_config =/usr/local/MySQL/bin/mysql_config near 12 rows.
Used to specify the installation location of MySQL
Continue to execute Python setup. py build,
Then install sudo Python setup. py install. The installation is complete.
Test import mysqldb in the command line and an error is reported.
Traceback (most recent call last ):
File "<stdin>", line 1, in <module>
File "mysqldb/_ init _. py", line 19, in <module>
Import _ MySQL
Importerror: dlopen (/library/Python/2.7/Site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_ mysql. So, 2): library not loaded: libmysqlclient.18.dylib
Referenced from:/library/Python/2.7/Site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_ mysql. So
Reason: image not found
Solution: create a "shortcut" for libmysqlclient.18.dylib"
Sudo ln-S/usr/local/MySQL/lib/libmysqlclient.18.dylib/usr/lib/
If you execute import mysqldb again, there will be no errors.