This forum has been archived. All content is frozen. Please use KDE Discuss instead.

launch python script without terminal?

Tags: None
(comma "," separated)
tubbadu
Registered Member
Posts
21
Karma
0
Hi, how can I execute a python script doubleclicking on it? i tried to make it executable by typing
Code: Select all
chmod +x filename.py

I added
Code: Select all
#!/usr/bin/python3

at the beginning of the file (i tried also env python3, pithon, env python), but I still can't open it with a doubleclick... if i right click it and select 'open with' and search for python, no result appears. but python 3 is installed, and if in a terminal I type
Code: Select all
python3 filename.py

it works

i don't know what to do, please help me! :'(
thank you in advance!
User avatar
thunder422
Registered Member
Posts
81
Karma
1
OS
The first time I tried this on a python script (that contained the line you mention, plus had the execute permission set), Dolphin asked if I wanted to execute the file. This dialog also contained an option if "Do not ask again". After selecting this, from then on, double-clicking the file ran the script (or any python script). Question, will your script run from the command line without first typing 'python3', in other words, just:
Code: Select all
filename.py
It does for me.


Currently running KDE Neon 5.22.5 and 5.19.4 (with Windows 10 in a VM); migrated from Linux Mint 17.3
tubbadu
Registered Member
Posts
21
Karma
0
thunder422 wrote:The first time I tried this on a python script (that contained the line you mention, plus had the execute permission set), Dolphin asked if I wanted to execute the file. This dialog also contained an option if "Do not ask again". After selecting this, from then on, double-clicking the file ran the script (or any python script). Question, will your script run from the command line without first typing 'python3', in other words, just:
Code: Select all
filename.py
It does for me.


sorry, I completely forgot to answer to this topic!
yes, typing just the name works, and doubleclicking does open the "do not ask again" window, but if in this window I select execute, it just open the text editor (which is the default program to open), the only way I found to execute it clicking on it is assigning it python as the default program to open it, so I'm not executing it, but opening it with the interpreter

is it normal this behaviour? or there is something messed up in my settings? :(
bye!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], q.ignora, watchstar