gconrad
Posts: 2
Joined: Thu Sep 05, 2013 12:45 am

Double clicking icon

Thu Sep 05, 2013 12:48 am

I am a beginner, why won't a Python program run when I double click it on the R-Pi like it does in MS Windows?

Angelus88
Posts: 442
Joined: Mon May 13, 2013 9:25 am
Location: Ivrea, TO (Italy)

Re: Double clicking icon

Thu Sep 05, 2013 8:34 am

Because every file is, at first, treated as a text document. If you double click the file, it probably asks to open it as text.
If you want to execute the python script with a double click, you probably have to make the file executable by doing:

Code: Select all

chmod +x nomefile

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: Double clicking icon

Thu Sep 05, 2013 9:09 am

Two more things you need to do -

1. tell the shell that this file is to be processed by python.

You do that by putting a 'shebang' line as the first line in the script. Details here - docs.python.org/2/using/unix.html


2. you need to be mindful of where your script will get its input and send its output. If you run the script from the command line or from idle the answer will be 'the console'. If you double-click an icon to execute it, what will happen?
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Return to “Beginners”