Python, Brew, and MySQLdb

故事扮演 提交于 2019-12-02 20:56:29

In trying to duplicate your error I did the following (I assume, being a homebrewer, you have done the same).

1) brew install python To install Python 2.7
2) brew install mysql To install mysql to the system (needed for various drivers)
3) Configured mysql per homebrew's recommendations
4) Downloaded mysql_python and unzipped it
5) Installed mysql_python using python setup.py install
6) Tested it in an interactive session python, import _mysql

After walking through these steps on Lion, I was unable to reproduce your error. Now... on to debugging your issue.

A few things to check:
1) In your terminal when you type which python does it point to your homebrew install?
2) Keep in mind that with homebrew the site-packages are not stored in the Cellar they are stored in /usr/local/lib/python2.7/site-packages. See this post for more info on why. I have not had to add the site-packages' location to my PATH, but you might give that a try.
3) The last thing I could suggest to try is in order to get easy_install to work with homebrew's python I had to add /usr/local/share/python to my PATH.

EDIT
After re-reading the error messages mainly after scrolling all the way to the right, I noticed that it was unable to load a mysql library. A quick google search on that library made it seem that when installing mysql on OS X there can be difficulties linking to it. Try and locate the file libmysqlclient.18.dylib and note down it's path. After installing mysql via homebrew mine is : /usr/local/Cellar/mysql/5.5.14/lib. The common fix I have seen fix the environment variable DYLD_LIBRARY_PATH. For more information where I got this check out this site. Using my path's as an example I would add this line to my .bash_profile

export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/Cellar/mysql/5.5.14/lib"

If this does not work for you, I would strongly look into the possibility that mysql isn't installed correctly or is having issues. With that mindset hopefully something will pop out at your.

Lastly, if you do not have any sql databaes yet, might I suggest uninstalling mysql and installing it via homebrew? I am now having zero trouble with that setup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!