Mac下安装MySQLdb

本来以为使用easy_install安装MySQLdb很简单,结果还是费了一点劲才安装好。

问题及解决办法:

  1. easy_install MySQLdb提示
    Couldn’t find index page for ‘MySQLdb’ (maybe misspelled?)
    No local packages or download links found for MySQLdb
    error: Could not find suitable distribution for Requirement.parse(‘MySQLdb’)
    原来MySQLdb在pypi上面叫MySQL-python
    解决办法:使用easy_install MySQL-python可以找到了,第2个问题也就出现了
  2. easy_install MySQL-python提示
    EnvironmentError: mysql_config not found
    这个问题是因为找不到mysql_config的原因导致的,不知道安装时候用mysql_config做了什么,解决办法有2个,网上都是说改site.cfg里面的mysql_config路径,但我使用easy_install没办法改
    解决办法:在PATH里增加/usr/local/mysql/bin解决
  3. import MySQLdb提示
    Library not loaded: libmysqlclient.16.dylib
    解决办法:使用export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/解决
  4. eclipse+pydev运行的时候还是和3一样的错误提示
    解决办法: eclipse->偏好设置->Pydev->Interpreter-Python->Environment里面增加下面内容,看图:

我的MySQL版本是5.5.x

This entry was posted in Python and tagged , , . Bookmark the permalink.

2 Responses to Mac下安装MySQLdb

  1. Pingback: pymysql - python - 开发者问答

  2. Pingback: MySQL skills | Raw notes here. http://dennyzhang.com is better

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>