Having problems using MySQLdb with pyjs

69 Views Asked by At

I want to use pyjs as the interface for an application I've already built and tested. It uses external libraries, including MySQLdb. I was hoping that I could integrate it nicely with pyjs, but have been receiving errors saying

 ImportError: No module named MySQLdb, MySQLdb in context None

Now when I run my program without pyjs, I do not get this error and all works well. But even just a simple pyjs script like this one

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)

gives me the error mentioned above.

How can I use MySQLdb in this fashion or, if I can't, is there a simple alternative? I feel like from this post it should be possible. I can get pyjs to work on examples that do not use MySQLdb. Right now, I'm just developing on my local machine.

1

There are 1 best solutions below

0
On

I guess this problem occured by different python version

try the command below

apt-get install python-mysqldb

I met same question and use that comm