Results 1 to 3 of 3

Thread: Double click python to run

  1. #1
    Join Date
    Sep 2010
    Beans
    29
    Distro
    Ubuntu 14.04 Trusty Tahr

    Double click python to run

    Is it possible to make anything a user could double click to run a python command, without opening terminal, navigating to the file, and typing in "python2.7 file.pyc" or making a menu shortcut. Just a shell script would do, but they don't seem to run with a double click.

  2. #2
    Join Date
    Oct 2011
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Double click python to run

    Quote Originally Posted by olligobber View Post
    Is it possible to make anything a user could double click to run a python command, without opening terminal, navigating to the file, and typing in "python2.7 file.pyc" or making a menu shortcut. Just a shell script would do, but they don't seem to run with a double click.
    Steps to do this
    Example will be to create an executable Python module on your Desktop

    1) Create a python module with .py extension
    open a terminal
    gedit file.py

    2) Add the shebang line as the first line in the Python module- this says use Python
    #!/usr/bin/env python

    3) Add Python code you want to execute
    print "Works..."
    raw_input('Press enter to close...')

    4) Save file to Desktop
    5) Run this to from a terminal to make the program executable
    cd Desktop
    chmod +x file.py

    6) Double click on the file and select run in terminal

  3. #3
    Join Date
    Sep 2010
    Beans
    29
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Double click python to run

    Quote Originally Posted by Pynalysis View Post
    Steps to do this
    Example will be to create an executable Python module on your Desktop

    1) Create a python module with .py extension
    open a terminal
    gedit file.py

    2) Add the shebang line as the first line in the Python module- this says use Python
    #!/usr/bin/env python

    3) Add Python code you want to execute
    print "Works..."
    raw_input('Press enter to close...')

    4) Save file to Desktop
    5) Run this to from a terminal to make the program executable
    cd Desktop
    chmod +x file.py

    6) Double click on the file and select run in terminal
    It is steps 2 and 6 that are the most help.

    However, does running a .pyc file change anything?

    NOTE: I have not tried this solution. I will in the near-ish future.

    EDIT: Forgot to say thankyou

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •