0

Everything was working fine until I missed some formatting in a while loop.

Now, I can't even run empty programs without getting this error:

& C:/pathname/python3.10.exe c:/path2/test.py File "<stdin>", line 1

& C:/pathname/python3.10.exe c:/path2/test.py

^

SyntaxError: invalid syntax

Even this fails: print("Hello"). Any help would be appreciated.

while loop mistake

SyntaxError

bward
  • 11
  • Indentation in Python is **critically important thing**. You have incorrect indentation in your code. Check it, or even install PyCharm Community Edition. It will highlight problematic code locations. – Rafael Jul 13 '22 at 21:38
  • type `exit()` or press `ctrl+D` to go out of python inline interpreter in the terminal. I think you accidentally typed in `python` or `python3`. If you want to run python code `python .py` or run with play button at top right – Bijay Regmi Jul 13 '22 at 22:18
  • why blank out some of the paths – rioV8 Jul 14 '22 at 05:09
  • kill all your terminals and try again, VSC will start a correct terminal – rioV8 Jul 14 '22 at 05:10
  • @Rafael I get this error even if the program is blank or a single line. – bward Jul 14 '22 at 05:26
  • @BijayRegmi The "exit()" command doesn't seem to do anything. I get the syntax error before it runs. I'm using VSCode on a PC, not a terminal or Terminal. I've been using the play button. Not sure why it stopped working. – bward Jul 14 '22 at 05:38
  • @rioV8 I'm not using a terminal. – bward Jul 14 '22 at 05:39
  • You are using the integrated Terminal of VS Code. You can close that terminal by clicking the trash icon on bottom right. After closing, if you press play after opening your python script, VSCode will spawn a new terminal. – Bijay Regmi Jul 14 '22 at 07:16
  • Does this answer your question? [Invalid Syntax error when running python from inside Visual Studio Code](https://stackoverflow.com/questions/51540391/invalid-syntax-error-when-running-python-from-inside-visual-studio-code) – mkrieger1 Aug 07 '23 at 22:27

0 Answers0