I can't seem to run my python code in VS code

Viewed 45

I'm a first year IT Student and relatively new to python and this is my first time using this HP laptop, running Windows 10 to code. I haven't encountered this problem before so I'm not sure what is wrong.

First error message displayed, when clicking the little play button to run the code in VS code

It seems to be some syntax error but I genuinely don't see anything wrong in my code. I tried again by writing "python (File Name)" and clicking enter and received another error message.

Second error message

The marked out parts are just my name and student number.

1 Answers

Short Answer:

VS code cmd

Fastest solution is to switch the vs code terminal from Powershell to Cmd.

On the drop-down there choose Cmd.

Long Answer:

Just set the path in the powershell.

Open Powershell and run it as an admin. Run this code: (copy, paste from here) “

[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Program Files\Python35-32")“

Note: Here, in Path, add the path where you’ve installed Python in your system, here in my case it is “C:\Program Files\Python35-32”.

It must have resolved the error.

To confirm, run this code:

“python --version”
Related