Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

3 Answers

up vote 12 down vote accepted

python <filename>.py

OR

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

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

And run it as ./<filename>.py

share|improve this answer
add comment

Just prefix the script's filename with python

i.e.:

  python python_file_name.py
share|improve this answer
add comment
python <filename.py>

pyw should run in the same manner, I think. You can also start an interactive console with just

python

Also, you can avoid having to invoke python explicitly by adding a shebang at the top of the script:

#!/usr/bin/env python

... or any number of variations thereof

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.