1

I am having a problem with my python.It is showing python failed to run error (https://i.stack.imgur.com/0ZI7z.png)

I tried to run simple python program in vscode, it is showing the error('python failed to run').when i entered the command(python --version) in command prompt ,it is showing python version, but it is throwing error in terminal.I tried to run my c++ files in vscode,they are working absolutely fine.my python version is python 3.11.4. so can anyone help me with this

  • 1
    Please, [DO NOT post images of code, data, error messages, etc.](https://meta.stackoverflow.com/a/285557), see [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – iRon Aug 15 '23 at 11:00
  • Why did you tag [tag:powershell]? What happens when you use the [tag:command-Prompt] (`cmd`)? – iRon Aug 15 '23 at 11:07
  • Duplicate? [Python and Powershell issue even after adding it to path](https://stackoverflow.com/q/58912217/1701026) – iRon Aug 15 '23 at 11:10
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 15 '23 at 12:24
  • after installing python (assuming you did that) and checking the option to add it to your path, you need to start a new shell to get the updated environment. – JonSG Aug 15 '23 at 14:14

2 Answers2

3

Add path of python (or python interpreter) in your environment variables, to run python on command line or shell.

Sauron
  • 551
  • 2
  • 11
1

This is because python.exe is not in your environment variables. Hence, PowerShell fails to locate your Python interpreter. You can address this problem by opening the configuration panel (type env in the Windows searchbar) then clicking, under Advanced System Settings, the Environment Variables... button. Then create a variable named python and assign the absolute path to your Python interpreter (the aforementioned python.exe) to it.

dbollu
  • 66
  • 3