繁体   English   中英

无法将MySQLdb导入python

[英]Can't import MySQLdb into python

我已经按照下面的网站中的步骤操作,并为MySQLdb安装了Everyhting。我在数据库中使用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

提前感谢您的所有帮助!

解决我的问题的是:

  1. 从此网站安装的自制软件: http : //brew.sh
  2. 使用brew安装mysql:

    brew安装mysql

  3. 跟随该网站来构建和安装python MySQLdb: http ://www.tutorialspoint.com/python/python_database_access.htm

一切都正常之后,所以如果有人在Mac上使用MySQLdb遇到麻烦,请按照这些说明进行操作。 我希望这有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM