I am new to python. I wrote a program which can be executed by typing python Filecount.py ${argument}
Why I see my teacher can run a program by only typing Filecount.py ${argument}
. How to achieve that?
To run the Python Shell, open the command prompt or power shell on Windows and terminal window on mac, write python and press enter. A Python Prompt comprising of three greater-than symbols >>> appears, as shown below. Now, you can enter a single statement and get the result.
py2exe is a Python extension which converts Python scripts (. py) into Microsoft Windows executables (.exe). These executables can run on a system without Python installed. It is the most common tool for doing so.
Make it executable
chmod +x Filecount.py
and add a hashbang to the top of Filecount.py
which lets the os know that you want to use the python interpreter to execute the file.
#!/usr/bin/env python
Then run it like
./Filecount.py args
in linux-based OSs you must include a line (at the beginning of your script, i.e., the first line) like this:
#!/usr/bin/python
this tells the OS to seek your python interpreter at that location. this applies to any script.
remember to have the permissions in your script file (i.e. executable) for that to work.
Add a shebang line to the top of your file: http://en.wikipedia.org/wiki/Shebang_(Unix)#Purpose
It will tell the system which executable to use in running your program.
For example, add
#!/usr/bin/env python
as the first line, and then change the permissions of the file so you can execute it.
chmod +x Filecount.py
Best of luck!
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