Suppose I have a python file named file.py. Normally to run this file from the command-line I would do:
python path\to\file\file.py
My question is, is it possible to do this without having the python
before the file path like so:
path\to\file\file.py
Or, if I have the path to file.py in my Environment Variables, simply just:
file.py
I suppose it's worth noting I want to do this with a python file that is going to accept command-line arguments. Thanks :)
The problem that you are facing is the fact that your python application is not actually an application. It is an interpreted script. This is because Python is an Interpreted Language.
This would be similar to you have a Word or Excel document. These are interpreted by their applications: Word and Excel, respectively. The operating system knows what application to use to interpret them using the registered associated programs.
The official Python FAQs explains this here: https://docs.python.org/2/faq/windows.html#how-do-i-make-python-scripts-executable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With