Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Where is the syntax error in my Python Script?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading