问题
I'm super new to programming and I'm using pycharm as my IDE.
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
Not sure why I get this error, I installed the Tk library as well and still get the error. I am using a Mac.
回答1:
If you are using python3 please use
import tkinter
回答2:
Well,if you are using python 3.8,In the install Setup,it has this choice:
If this couldn't solve your problem,Read the python official document:IDLE and tkinter with Tcl/Tk on macOS.
回答3:
To create a window with hello world use this
from tkinter import *
from tkinter.ttk import * # importing themed widget library
root = Tk() # creating the root master application object
label = Label(root, text="Hello World") # simple text: hello world
label.pack() #Places label into its parent
root.mainloop() # running the mainloop
来源:https://stackoverflow.com/questions/61347719/tkinter-configuration