Talk about the terminal directly execute py file do not need python command
- 2020-05-24 05:44:41
- OfStack
Then give the script file permission to run,
Method (1) chmod +x./*.py
Method (2) chmod 755./*.py (777 doesn't matter)
If this command is not adjusted, an permission denied error will occur
The terminal executes directly.
If a comment similar to the following is given at the beginning of the script content:
#! /usr/bin/env python (or #! / usr/bin/python)
That can be run directly from the terminal:
./*.py
If you don't have this comment
Execute in the terminal:
python ./*.py
(note: some versions of linux run on python even if the above comment says python in front of python as a command.
Otherwise, the file./*.py is not a command./*.py not found error will appear. The command can't be found, of course.)
If it's a script with a graphical interface
After chmod, just double-click to execute