-1

Whenever I try to run the VS code python terminal, I get the following error:

File "<stdin>", line 1
    & C:/Users/tawsi/AppData/Local/Microsoft/WindowsApps/python.exe c:/Users/tawsi/OneDrive/Desktop/Coding/Untitled-1.py
    ^
SyntaxError: invalid syntax

Here is a picture of the Error

How can I fix this?? Please help

2
  • 3
    You can't run a Python file from the REPL, it's for typing Python statements. Commented Oct 20, 2020 at 0:14
  • Refer to this post. There are multiple ways to run a python script. Commented Oct 20, 2020 at 0:30

2 Answers 2

3

This is because your current VSCode terminal is in the "Python interactive window", please try to use "exit()" to exit this interactive window, and then use the run button to execute the python script.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

If you just want to run the python file in the VS Code terminal you install the Code Runner extension, after which you can right click on the workspace and click the "Run Python File in Terminal" option.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.