When I try to run python ‘Run python file in terminal’ in vs code,I get this error in Terminal:

PS I:pythonExam> & ??/AppData/Local/Programs/Python/Python312/python.exe ??/Exam/S1/t1.py
Program ‘python.exe’ failed to run: Access is deniedAt line:1 char:1

  • & ??/AppData/Local/Programs/Python/Python312/python.e …

At line:1 char:1

  • & ??/AppData/Local/Programs/Python/Python312/python.e …
  •   + CategoryInfo          : ResourceUnavailable: (:) [], ApplicationFailedException
      + FullyQualifiedErrorId : NativeCommandFailed

?? is installation directory
my code is very simple:

print(‘Hello World!’)

I can run my code in ‘Run current file in interactive window’ without any error.
My environment specifications:
windows 11 x64
python 3.12.2
vs code 1.87.2

What is the reason for this problem?

I try to run my python code in windows cmd and everything is good.

New contributor

user24004622 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.