'I'm getting name error while coding to make YouTube downloader [closed]
This the code which I'm using to create a GUI for YouTube video downloader
#import) tkinter as tk
# Create the main window
root = tk.Tk()
root.title("My GUI")
# Create label
label = tk.Label(root, text="Hello, World!")
# Lay out label
label.pack()
# Run forever!
root.mainloop()
I'm getting error something like this below in my Terminal
Traceback (most recent call last):
File "YoutubeVideoDownloader.py", line 4, in <module>
root = tk.Tk()
NameError: name 'tk' is not defined
Process finished with exit code 1.
please look at the Image I've shared here
Solution 1:[1]
You need to install the package first, you can do that by using pip. Run this on your project directory folder using some sort of cmd / terminal.
pip install tk
Just un-comment the import
import tkinter as tk
The line above tells python to import the library tkinter as tk. You can then use tk.TK() to initialize tkinter library.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
