Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a .py file and saved it in my "Python" folder located on my desktop. Now, I want to execute that particular file named "".

How can I execute the file using LXTerminal?

share|improve this question
possible duplicate of run python in terminal – Eliah Kagan Sep 10 '14 at 0:38

You've got several options here (choose the one you like best):

  • Make the file itself executable.

    1. On the first line of the file, make sure the "shebang" is there:

      #!/usr/bin/env python

      This is needed for the shell so that it knows how to run the file.

    2. Mark the file executable on the filesystem:

      chmod +x
    3. Run it like any other executable:



  • Run the file directly in the Python interpreter:


    The disadvantage of this is that everyone who would like to run the file should know how to call it. With the first option you have this inside the file itself and you can run the file without knowledge of that.

share|improve this answer
I think that the shebang way should be promoted over directly calling the interpreter. It's not that hard and is present in any script I write. – minerz029 Oct 17 '13 at 12:04

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.