Python web.py连接到mysql错误

Python web.py连接到mysql错误,python,mysql,web.py,Python,Mysql,Web.py,当我使用web.py连接本地mysql时,出现一些错误: Traceback (most recent call last): File "code.py", line 7, in <module> db = web.database(dbn='mysql',user='root',pw='123456',db='pytable') File "/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg/web/db

当我使用web.py连接本地mysql时,出现一些错误:

Traceback (most recent call last):
  File "code.py", line 7, in <module>
    db = web.database(dbn='mysql',user='root',pw='123456',db='pytable')
  File "/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg/web/db.py", line 1078, in database
    return _databases[dbn](**params)
  File "/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg/web/db.py", line 928, in __init__
    import MySQLdb as db
  File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/rlog/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
    /Users/rlog/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture
我的python版本是2.6.1

我怎样才能修好它


谢谢

您为Python安装的mysql适配器已损坏或采用了不同的体系结构。我不知道你是如何安装的,也不知道这些东西在OSX上是如何工作的。这是关于安装的。如果你做对了,假设凭证是正确的,它应该可以正常工作。

db=web.databasedbn='mysql',db='projefg9\u emeagramy\u ps\u erc',user='root', pw='admin'

其中dbn—您用于mysql的数据库是mysql 数据库名称 user-数据库的用户名
pw-您数据库的密码

您是如何安装mysql软件包的?似乎有点奇怪:/mysql服务器似乎没问题。我使用php连接到它,一切正常抱歉,我不清楚,我没有谈论mysql服务器,而是python mysql包:
import web
render = web.template.render('templates/')
urls = (
    "/(.*)","index"
)
app = web.application(urls,globals())
db = web.database(dbn='mysql',user='root',pw='123456',db='pytable')
class index:
    def GET(self):
        todos = db.select('todo')
        return render.index(todos)
if __name__=="__main__":app.run()