【发布时间】:2014-11-22 19:20:26
【问题描述】:
我已按照以下网站中的步骤安装了 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
提前感谢您的帮助!
【问题讨论】:
-
你知道 MySql 必须作为一个包下载和安装吗?你是用
pip安装的吗? -
@sammy 不,我没有。我刚刚从网站上下载了文件并按照他们的说明进行操作。顺便说一句,我在 Mac 上。
-
好的。但我也在使用 MySqldb,这对我来说很好用。我的答案马上就来了
-
and I have linked the mysql_config to the xampp mysqlconfig- 这是两个不同的命令,因此将一个命令链接到另一个命令会破坏而不是修复它们。 -
哦!我想我误解了mysql_config。我刚刚做的是我用brew来安装mysql。然后我又做了 python setup.py build 和 python setup.py install 。现在一切正常。对不起,我还是个初学者。但是,谁能向我解释一下mysql_config。我还可以使用 xampp 数据库通过 python 连接吗?谢谢!
标签: python mysql database import