I get a syntax error about File "<stdin>", line 1

Question:

This is the error, I have no idea where the fault is:

> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe  
"c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
  File "<stdin>", line 1
    & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
    ^
SyntaxError: invalid syntax
Asked By: Servus Vitae

||

Answers:

You’re getting a Python SyntaxError because you are trying to run a PowerShell command in the Python shell:

>>> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"

exit out of that shell and then run your PowerShell command in PowerShell. The prompt should look something like

PS C:>

The Python shell is for running code interactively, e.g. you could type something like import pygame or print("Hello, world!") directly into it.

Answered By: Chris

To solve this error, just write this command in your terminal :

>>> exit()
Answered By: Arpit Kushwaha
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.