Install mysql-python on Mac

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.