When you install python on windows with a regular installer, .py files are associated with the python.exe you installed. When you type Welcome.py
, Windows searches the local directory and then all paths in the PATH variable for a program called Welcome.py and runs it via python. Since this worked for you, it means that Welcome.py is somewhere on your path or in your local directory.
You can figure out your file associations with the assoc .py
and ftype Python.File
commands. The echo %PATH%
and echo %PATHEXT%
commands are also useful.
When you type python Welcome.py
, Windows searches all paths in the PATH variable for a program that starts with 'python' and ends with an extension in PATHEXT. It finds 'python.exe' and runs it. Python in turn looks for a script called Welcome.py in the current directory. Since this didn't work for you, it means that Welcome.py is not in your local directory. It would have worked if you had given the right path to Welcome.py.
You can find out where Welcome.py is with the (not surprisingly) where Welcome.py
command.
If you only have a single python installation, there is no need to call python myscript.py ...
.