Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

RIght now, I type "python myfile.py" to run it.

How can I type "py myfile.py" to run it? Or better, do this ./myfile.py?

Any tips?

share|improve this question

2 Answers 2

You can add this as the first line of your python script:

#!/usr/bin/env python

Which will allow you to run your script as:


But you must make sure you make your python script executable:

chmod +x myfile.py
share|improve this answer
And if you want to skip adding the ./ place the script somewhere in your path. For extra points rename the file and skip adding the .py extension. –  Zoredache Jun 22 '10 at 23:21
alias py='python'
share|improve this answer

Your Answer


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.