Please tell me how to execute python file in Ubuntu by double clicking on file.

Michael Torrie torriem at gmail.com
Mon Dec 4 19:03:02 EST 2017


On 12/04/2017 04:49 AM, Thomas Jollans wrote:
> On 2017-12-04 10:48, dhananjaysingh091298 at gmail.com wrote:
>> Respected Sir/Mam,
>>         I am Dhananjay Singh,Student of IIIT Manipur. Sir/Mam when i am double click in python program (Dhananjay.py),it is opening in Text Editor by Default in Ubuntu.I want to run this program when i double click on it as any *.Exe file executes as in Window.
>> Sir please help me.
>>
> 
> https://askubuntu.com/a/544544

Oops! You misread his question. The question was, how can he run a
python script by simply double clicking on it in the file browser in
Ubuntu?

Now I don't know the answer to that question, but I can say that nearly
all the time you just don't want to do that anyway, for reasons I state
below.

Instead, open a terminal, change to the directory where you python
script is and either run it directly (if it's chmod'd as exectuable)
using "./myscript.py" or use the python interpreter: "python3
/path/to/myscript.py"

The reason scripts are rarely launched from the file browser like you
want to do is that often scripts communicate with the user via standard
out, so you need to run them from a terminal.

There are some GUI programs written in Python, but those are usually
launched from a .desktop file shortcut.






More information about the Python-list mailing list