Skip to content

"Run Python File" returned an error but "Run Python File in Dedicated Terminal" could run successfully. #614

@lincj1994

Description

@lincj1994
x = 3
while x > 0:
    x -= 1
    print(x)

I run the above code with Run Python File in vscode and it returned an error:

>>> D:/Python313/python.exe c:/Users/colin/Desktop/PracticeAI/PracticeAI.py
  File "<python-input-7>", line 1
    D:/Python313/python.exe c:/Users/colin/Desktop/PracticeAI/PracticeAI.py
      ^
SyntaxError: invalid syntax

When I use Run Selection/Line in Python Terminal, it also returned an error:

>>> x = 3
>>> while x > 0:
...                 x -= 1
...                     print(x)
... 
  File "<python-input-9>", line 3
    print(x)
IndentationError: unexpected indent

But when I use Run Python File in Dedicated Terminal, it could run smoothly.

C:\Users\colin\Desktop\PracticeAI>D:/Python313/python.exe c:/Users/colin/Desktop/PracticeAI/PracticeAI.py
2
1
0


Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions