我已按照下面网站中的步骤操作,并为MySQLdb安装了每个人。我正在使用Xampp作为数据库,我已将mysql_config链接到xampp mysqlconfig。
http://www.tutorialspoint.com/python/python_database_access.htm
但是,在安装完所有内容后,当我尝试导入它时说:
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.9-intel.egg/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.9-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.9-intel.egg/_mysql.so
Reason: image not found
提前感谢您的帮助!
答案 0 :(得分:0)
解决了我的问题是:
使用brew安装mysql:
brew install mysql
关注本网站构建并安装python MySQLdb:http://www.tutorialspoint.com/python/python_database_access.htm
所有这一切都完美无缺。如果有人在Mac上遇到MySQLdb问题,那么就按照这些说明进行操作。我希望这有帮助。