I saved the first.py in a folder called Python. I opened command line and went to that folder Python and then ran this command
python first.py
but got error message! then I tried to type python alone. When I typed python, a new window open (Microsoft store) and asked me if I want to install Python. After I installing Python again but this time from ms store, I managed to run that command
python first.py
I got an impression that installing python from ms store would take care of setting the path issue. Am I right? Thank you so much.
When you run the python.org installer for Windows, there should be an option to add its folder to the PATH. This isn’t the default because there needs to be a separate entry for each version of Python for this to work and they don’t want you to clutter your PATH or have issues with cleaning it up if you uninstall. (Windows gives every program in the “Program Files” a separate directory. On Linux, the actual Python executables would go directly in a folder such as /usr/bin, all side by side, and the support files would be somewhere else.)
There is also an option, which is default, to install the Python Launcher for Windows. This tool is described in the how-to guide that I linked you in the previous thread. It lets you run py first.py instead. This works by being installed directly in the Windows folder (so it’s always on the path); that program then uses its own logic to find Python, instead of the operating system’s logic searching the PATH.
This is expected. Windows comes with a wrapper program named python that opens the Microsoft store for you, and offers Microsoft’s installer for Python. This was the result of a deliberate collaboration between the PSF and Microsoft, but there were apparently some mis-communications and oversights that cause this strange chain of events.