Thursday, April 18, 2024
105
rated 0 times [  105] [ 0]  / answers: 1 / hits: 855986  / 1 Year ago, fri, april 14, 2023, 5:45:28

Trying to learn how to run my scripts through Ubuntu's terminal regularly. That being said I am familiar with bash, wget, and awk being called but how do I call python files to run in the terminal? I would like to learn this but I am unsure on where to research it. I have a .pyw file that references several .py files in a folder.


More From » command-line

 Answers
2

Option 1: Call the interpreter



  • For Python 2: python <filename>.py

  • For Python 3: python3 <filename>.py


Option 2: Let the script call the interpreter



  1. Make sure the first line of your file has #!/usr/bin/env python.

  2. Make it executable - chmod +x <filename>.py.

  3. And run it as ./<filename>.py


[#33158] Sunday, April 16, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eeperant

Total Points: 39
Total Questions: 106
Total Answers: 117

Location: Finland
Member since Sat, Dec 5, 2020
3 Years ago
;