I’m trying to make a GUI for a password logger program. Right now I’m only trying to learn how making a GUI works but only ten lines in, My program wont run because of a supposed syntax error.
import tkinter as tk
from tkinter import filedialog, Text
import os
root = tk.Tk()
canvas = root.Canvas(root, height=700, width=700, bg="#263d42")
canvas.pack()
root.mainloop()
This is the entire script. The error looks like this:
File "<stdin>", line 1 & c:/FileLocation/main.py"
^
SyntaxError: invalid syntax
I’ve tried removing unnecessary imports but I get the same issue.
I am only trying to get the program to display a canvas on the screen.
>Solution :
Looks like your problem is that you are trying to run python main.py from within the Python interpreter, which is why you’re seeing that traceback.
Make sure you’re out of the interpreter:
exit()
Then run the python main.py command from bash or command prompt or whatever.