Probem importing tkinter - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: Probem importing tkinter (/thread-18904.html) |
Probem importing tkinter - GarDebs - Jun-05-2019 Hi I'm trying to teach my son Python programming... we're using Spyder on Ubuntu. I'm trying to use this code... from tkinter import * import tkinter tk = Tk() canvas = Canvas(tk, width=500, height=400) tk.title("drawing") canvas.pack() canvas.mainloop()However,I keep getting this error ImportError: No module named tkinterI've tried installing python3-tk using apt-get but still no joy. Any suggestions would be greatly appreciated. Kind regards Gary RE: Probem importing tkinter - Yoriz - Jun-05-2019 If import Tkinter works you are using python 2, import tkinter is python 3.
RE: Probem importing tkinter - Denni - Jun-05-2019 And I have validated that as I am only using python 3.7 and I was able to copy that code and run it without issue. So if you do have python 3 loaded perhaps you are inadvertently still referencing python 2 RE: Probem importing tkinter - joe_momma - Jun-06-2019 tkinter is usually installed with the default install of python. Open up your teminal and enter: python3 you should have an output similar but with your version: then enter your import of tkinterimport tkinterif no error it's installed.. |