The Student Room Group

stdin error on vs code

I am typing a simple print('hello world') however I am getting these errors:

SyntaxError: invalid syntax
>>> print('end here')
end here
>>> & C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"
File "<stdin>", line 1
& C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"

I have looked all over google but I cant get a straight forward solution. I am very new to this, so could you please break down your answer!
Original post by Frank Peters
I am typing a simple print('hello world') however I am getting these errors:

SyntaxError: invalid syntax
>>> print('end here')
end here
>>> & C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"
File "<stdin>", line 1
& C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"

I have looked all over google but I cant get a straight forward solution. I am very new to this, so could you please break down your answer!

What are you trying to do on line:

>>> & C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"

It doesn't make sense. You're giving 2 file paths, one of which is encapsulated in quotes, with an '&' thrown into the mix. That entire line is the problem. What are you trying to do there? None of that is valid Python code. Hence why you're getting an error.

If you're trying to run a python file. You need to use the command prompt (type CMD in the Windows taskbar). And from there use the following:


python c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py


Or navigate to the folder via the command prompt and use

python Untitled-1.py
(edited 3 years ago)
Original post by Strange5050
What are you trying to do on line:

>>> & C:/Python32/python.exe "c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py"

It doesn't make sense. You're giving 2 file paths, one of which is encapsulated in quotes, with an '&' thrown into the mix. That entire line is the problem. What are you trying to do there? None of that is valid Python code. Hence why you're getting an error.

If you're trying to run a python file. You need to use the command prompt (type CMD in the Windows taskbar). And from there use the following:


python c:/Users/mahba/Desktop/Microsoft VS Code/Untitled-1.py


Or navigate to the folder via the command prompt and use

python Untitled-1.py


Yes I'm trying to get python code to run.

am I meant to have 1 file path? would vs code and python need to be in the same file location?

when I type in where python on CMD it gives me:
C:\Users\mahba\Desktop\python.exe
C:\Users\mahba\AppData\Local\Microsoft\WindowsApps\python.exe

should I only have one?

also my path environments look like this:
(edited 3 years ago)
sorry for this :frown: I was mainly using jupyter notebooks, and I dont know much about how to set these things up

Quick Reply