当我使用 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代码是这样的:
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()
我的 python 版本是 2.6.1
我该如何解决?
谢谢