Posts

Showing posts from June, 2021

File "stdin", line 1 — invalid syntax error in Visual Studio Code

Image
If you came across this error, keep on reading to learn how to fix it.  File "<stdin>", line 1     & C:/Users/Chanaka/AppData/Local/Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.9/python.exe g:/CP/hello_world.py     ^ SyntaxError: invalid syntax I got this error for a simple hello world python code. Python files cannot be run within the interpreter. Sounds weird right? Python cannot be run within Python! 🙄  I know why but my thought process is not quite clear. Until I process my thoughts, try THE fix. I wish the error message was descriptive for noobs like me.  FIX Type exit() in the Visual Studio Code terminal and press enter, as shown below. Then run the Python file in the terminal. Ta Da! You should not see this error again.  Happy Pythoning.