0

When I try to run a python command in Powershell, I get this error

Program 'python' failed to run: No application is associated with the specified file for this

I have python installed in C:\Users\hp\AppData\Local\Programs\Python\Python35 directory. I tried adding it with in the system environment variable path and restarted Powershell but get the same error. Also tried doing it via the commands given in other answers, but it doesn't work

4 Answers4

1
  1. Make sure you can start python by typing C:\Users\hp\AppData\Local\Programs\Python\Python35\python.exe in powershell.

  2. Make sure the C:\Users\hp\AppData\Local\Programs\Python\Python35 already added to PATH.

  3. Restart your system.

ibndias
  • 107
  • 10
  • Your answer has already been liked so congrats on helping someone else on Stack Overflow out. You might want to explain how or why this answer works. When I read it, I think adding Python35 to the start of your path should make it available by simply running "python.exe", so why are both needed? Also why do you suggest restarting the system? That (to me) is strange. Welcome to SO and thanks for helping folks out. – PatS Nov 18 '19 at 17:46
0

If this is for windows then you don't have to mention the path explicitly as just clicking "Add to the path" takes care of it.

Most likely you didn't give the exact path ie C:\Users\hp\AppData\Local\Programs\Python\Python35 while setting it during installation.

Does Python run when you give an exact path while executing the script? If nothing else works try restarting the system or reinstall Python and make sure the "Add to path " box is checked.

0

You might need to restart your computer for the new path to take effect, just restarting powershell will not work.

Alve
  • 640
  • 2
  • 9
  • 19
0

Go to setting, Apps, App execution aliases, then turn off App installer option for both python.exe and python3.exe. After that your path to the installed python should work properly.

Ramin
  • 1