在pyjs中使用MySQLdb时遇到问题

2024-05-15 23:17:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想使用pyjs作为我已经构建和测试的应用程序的接口。它使用外部库,包括MySQLdb。我希望我能很好地将它与pyjs集成,但一直收到错误消息

 ImportError: No module named MySQLdb, MySQLdb in context None

现在,当我在没有pyjs的情况下运行我的程序时,我没有得到这个错误,所有的工作都很好。但即使只是像这样一个简单的pyjs脚本

from pyjamas.ui.Button import Button
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.HTML import HTML
from pyjamas.ui.HorizontalPanel import HorizontalPanel
import MySQLdb

def run_fcm(sender):
    db=MySQLdb.connect(host="00.00.00.00", port=0000, user="user_name", passwd="pwd", db="db_name")

if __name__=='__main__':

    input_header=HTML('Input')
    generate_prediction=Button("Generate Prediction", run_fcm)
    RootPanel().add(input_header)
    RootPanel().add(generate_prediction)

给我上面提到的错误

如何以这种方式使用MySQLdb?如果不能,有没有简单的替代方法?我觉得从this post这应该是可能的。我可以让pyjs处理不使用MySQLdb的示例。现在,我正在本地机器上开发


Tags: runnamefromimportuidbhtml错误