Let's say I have a python file named myfile.py in a certain directory. How do I just call the python file directly without invoking python.
myfile.py
and not
python myfile.py
Edit:
To be more precise.
just typing the filename in the command line will not work.
Typing start program.py
however should work.
Windows normally has information telling it which program is the default program for a given suffix.
Concerning @go2nirvan's comment: Though windows is not an oracle, it can have information for each file suffix to know what's the related default application. Even many linux desktop application associate a default application to certain mime types.
If you click on .xls (depending on what is installed) either Excel, or OpenOfficeCalc or LibreOffice will be opened)
Windows associates file suffixes to file types and file types to applications, that are supposed to start it.
If you open a CMD window and you type
assoc .py
You should get an output similar to: (I don't have a windows machine nearby, so can't tell you the exact output)
.py=Python.File
Then type
ftype Python.File
or whatever the previous command gave you and you should see which executable shall be used.
This should be something like
c:\System32\py.exe
which is a wrapper program, calling the real python executable according to some rules
If this doesn't work, then please tell which version of python you installed and how you installed it (for all users, for current user, ...)
From command line you have to call (If I recall correctly)
start test.py
and it will execute the file with the associated executable
.py
files, so you have to specify what program to run it with. I guess, there could be some way to run it with python if no other is specified, but why would you even want that in the first place?.bat
file which starts that program with your chosen version of python.