0

However simple my python script is, I cannot get it running inside VSCODE Terminal by clicking on the "RUN" icon at the top right, whereas it runs fine when called from a CMD window

enter image description here

2
  • What's the & for there? Commented Feb 2, 2021 at 11:43
  • No idea, I just click on the Run button Commented Feb 2, 2021 at 11:50

3 Answers 3

1

I had the same problem, this thread helped me I get a syntax error about File "<stdin>", line 1

You are now working inside your Python shell (>>>) while the code you are running (& python "FILENAME.py") is no Python, therefore syntax error.

    exit()

to exit the python shell and return to the PowerShell environment.

Simply

    python

to enter again, to run python code directly

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I will try it again. The fact is the python was incorrectly declared inside vscode. I had to reboot.
0

It seems python is not recognized in your PATH variable. I think the 2 ways to fix are to find your python filepath and adding it your User Variables:

  • Control panel > System > advanced settings > Advanced tab > Environment Variables
  • select PATH and then click edit..
  • in a new line add the path to your python installation (ie C:\Users\YOURUSERNAME\AppData\Local\Programs\Python\Python38-32)

OR, not sure this works out of the box but you could:

  • install Python module from within VS Code, published by Microsoft

3 Comments

Thx, I have done that already, and it is working OK inside a CMD window
Just out of curiosity, is VS code recognizing the version of Python you're using (bottom left of purple bar)?
Yes, indeed, once restarted
0

After editing the PATH as suggested by @mah111, I needed to restart VSCODE application

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.