Reputation: 67
I am trying to make my python script executable without going through the terminal typing like
python test.py
I want to make it able to run when i click on the file.
How i going to do this in my fedora machine.
Upvotes: 3
Views: 14700
Reputation: 1
I use raspibian os (Linux)
Upvotes: 0
Reputation: 34
I know it can be too late, but i did have the same idea. (run python scripts in fedora) and found some trouble. My suggestion to you is to make a launcher with a .sh
file, like this:
#!/bin/sh
gnome-terminal -x python yourscript.py
Give the permition to execute with chmod +x file.sh
, them click and will run.
[^_~]
Upvotes: 0
Reputation: 11
It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences. Select the "Behaviour" section. On the field titled "Executable text files", select the option "Execute executable text files when opened".
Upvotes: 1
Reputation: 2369
#!/usr/bin/env python
at the very beginning of file.chmod u+x filename.py
.py
to .sh
, so your linux distro's UI will recognize it as shell script and try to execute.Upvotes: 3
Reputation: 174632
Add #!/bin/python
as the very first line of your file. Or, if you don't know where your python executable is, type which python
in a terminal; then copy the result of that and put it after the #!
.
Change the permissions of the file so that its executable chmod u+x test.py
i try but it still open back as gedit
python
in the command to be added.Upvotes: 5
Reputation: 7423
If you don't have any specific version requirement then using first line as #!/usr/bin/env python
will be more efficient and give the execute permission chmod u+x test.py
Upvotes: 0
Reputation: 28768
Add #!/usr/bin/python
as the first line of the file and set the permission to executable chmod 755 yourfile
.
Upvotes: 0