python 在 eclipse 中使用 MySQL 的问题
示例:
import MySQLdb
conn = MySQLdb.connect(passwd="passwd", db="mydb")
cursor = conn.cursor()
cursor.execute("""SELECT * FROM table""")
records = cursor.fatchone()
print records
提供下一个错误:
回溯(最近一次调用最后一次):文件
“/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py”,
第 1267 行,位于
debugger.run(setup['file'], None, None) 文件 "/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py", 第 1020 行,正在运行
pydev_imports.execfile(file, globals, locals) #执行脚本 File "/Users/user/Documents.Develop/workspace/myProject/src/Main.py",
第 56 行,位于
导入 MySQLdb 文件“build/bdist.macosx-10.7-intel/egg/MySQLdb/init.py”,第 19 行,位于
文件“build/bdist.macosx-10.7-intel/egg/_mysql.py”,第 7 行,
在文件“build/bdist.macosx-10.7-intel/egg/_mysql.py”中,行
6、在bootstrap中导入错误:
dlopen(/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so,
2): 库未加载:libmysqlclient.18.dylib 引用自:
/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
原因:找不到图片
错误在哪里?
Example:
import MySQLdb
conn = MySQLdb.connect(passwd="passwd", db="mydb")
cursor = conn.cursor()
cursor.execute("""SELECT * FROM table""")
records = cursor.fatchone()
print records
provides the next error:
Traceback (most recent call last): File
"/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py",
line 1267, in
debugger.run(setup['file'], None, None) File "/Applications/eclipse/plugins/org.python.pydev.debug_2.2.2.2011100512/pysrc/pydevd.py",
line 1020, in run
pydev_imports.execfile(file, globals, locals) #execute the script File "/Users/user/Documents.Develop/workspace/myProject/src/Main.py",
line 56, in
import MySQLdb File "build/bdist.macosx-10.7-intel/egg/MySQLdb/init.py", line 19, in
File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7,
in File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line
6, in bootstrap ImportError:
dlopen(/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so,
2): Library not loaded: libmysqlclient.18.dylib Referenced from:
/Users/user/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so
Reason: image not found
Where's the error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误似乎在这里:
确保安装了 mysqldb 库。
请参阅:如何安装 MySQLdb 包? (导入错误:没有名为 setuptools 的模块)
和/或: http ://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
您的 代码:
The error seems to be here:
Make sure you install the mysqldb library.
See: How to install MySQLdb package? (ImportError: No module named setuptools)
and/or: http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
You also have a syntax error in your code: