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

3
  • Can you show what your path looks like? Commented Nov 18, 2019 at 10:18
  • Try this: stackoverflow.com/questions/36390371/… Commented Nov 18, 2019 at 10:20
  • 1
    @DuarteCastanho Thanks! Get-Command python | Select-Object -ExpandProperty Definition returned cygwin. I moved Python up in the variables list and it started working. Commented Nov 18, 2019 at 15:59

4 Answers 4

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.

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

1 Comment

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.
1

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

Comments

1

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.

Comments

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.

1 Comment

Thanks! I had already tried this. I moved Python up in the variables list and it started working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.