'Why is 'python' not recognized in powershell?

I have installed python 3.6 in my Windows 10 PC. I also use Pycharm to make my scripts. It runs perfectly fine there. But my problem is I can't run python in powershell. I am told to simply type 'python' in powershell and it should automatically start python. But, I get an error saying it's not recognised.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\lenovo> python
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Some suggested to type this:

[Environment]::SetEnvironmentVariable("Path", "$enc:Path;C:\Users\lenovo\AppData\Local\Programs\Python\Python36") 

The path given in the above code is correct for my PC. Infact, Python runs after I give the above code. But, that is my problem. Every time I close and open powershell again, I have to type the above code to get python running. I tried typing this in Powershell running as an admin too. But, it doesn't work. I even tried restarting my PC, still the problem refuses to resolve.

I am expected to type the above code every time I want to run python in a new powershell window. This is a bit annoying. Any help would be appreciated. Thanks.



Solution 1:[1]

You need to add the path to your environment variables:

Control Panel>System and Security>System>Advanced System Settings>Environment Variables

Select edit PATH and append:

C:\Users\lenovo\AppData\Local\Programs\Python\Python36

to the path. Hit apply and ok. After closing and reopening the shell you should be able to type "python" and be in the python shell.

Solution 2:[2]

Or just simply type 'py' instead of 'python' in the PowerShell and hit enter.

Check out the image to see how it worked.

Solution 3:[3]

Check out your config path

Maybe look like : C:\Users\lenovo\AppData\Local\Programs\Python\Python36\

Change it to : C:\Users\lenovo\AppData\Local\Programs\Python\Python36

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cosmic_inquiry
Solution 2 Suraj Rao
Solution 3 H?o Nguy?n