Xherdi Lika Xherdi Lika - 5 months ago 16
SQL Question

Error: No module named 'mysql'

I'm doing a project that requires to create a python gui and use c functions. I have tried installing mysql-python but It doesn't work. I'm using python3.4, xubuntu 16.04. Please tell me what can be the problem?

from ctypes import *
# Simple enough, just import everything from tkinter.
from tkinter import *
from tkinter import filedialog
from tkinter.filedialog import askopenfilename
import subprocess
# Here, we are creating our class, Window, and inheriting from the Frame
# class. Frame is a class from the tkinter module. (see Lib/tkinter/__init__)
import mysql.connector

cnx = mysql.connector.connect(user='root', password='root',

cal = CDLL('./caltool.so')
class Window(Frame):

# Define settings upon initialization. Here you can specify
def __init__(self, master=None):

# parameters that you want to send through the Frame class.
Frame.__init__(self, master)
fm = Frame(root, width=400, height=300, bg="green")
fm.pack(side=TOP, expand=NO, fill=NONE)
#reference to the master widget, which is the tk window
self.master = master

#with that, we want to then run init_window, which doesn't yet exist

#Creation of init_window
def init_window(self):

# changing the title of our master widget
self.master.title("XCal Application")

# allowing the widget to take the full space of the root window
self.pack(fill=BOTH, expand=1)

# creating a menu instance
menu = Menu(self.master)

# create the file object)
file = Menu(menu)

# adds a command to the menu option, calling it exit, and the
# command it runs on event is client_exit
file.add_command(label="Open", command=self.OpenFile, accelerator="Ctrl+O")
file.add_command(label="Save", command=self.file_save, accelerator="Ctrl+S")
file.add_command(label="Save As...", command=self.client_exit, accelerator="Ctrl+Shift+S")
file.add_command(label="Combine", command=self.client_exit)
file.add_command(label="Filter", command=self.client_exit)
file.add_command(label="Exit", command=self.client_exit, accelerator="Ctrl+X")
self.bind_all("<Control-x>", self.client_exit)
self.bind_all("<Control-o>", self.OpenFile)
self.bind_all("<Control-s>", self.file_save)

#added "file" to our menu
menu.add_cascade(label="File", menu=file)

# create the file object)
edit = Menu(menu)

# adds a command to the menu option, calling it exit, and the
# command it runs on event is client_exit
edit.add_command(label="To Do List", accelerator="Ctrl+T")
edit.add_command(label="Undo", accelerator="Ctrl+Z")

#added "file" to our menu
menu.add_cascade(label="Todo", menu=edit)
help1 = Menu(menu)
help1.add_command(label="Date Mask")
help1.add_command(label="About xcal")
menu.add_cascade(label="Help", menu=help1)

def client_exit(self, event):
def OpenFile(self):
filename = askopenfilename()
def file_save(self, event):
name = asksaveasfile(mode='w',defaultextension=".txt")

# root window created. Here, that would be the only window, but
# you can later have windows within windows.
root = Tk()


#creation of an instance
app = Window(root)



Python versions can be confusing, especially if you install with apt. mysql-python is a python 2 package. You probably want to install this one

sudo apt-get install python3-mysql.connector