running python 3 scripts from graphical file manager

To run my own python 3 scripts I’ve taken these steps:

  • added the shebang to the top of the script
  • copied the script to /usr/local/bin
  • chmod +x on the copied script to make it executable
  • chown the script to my limited user account

This has enabled me to run scripts successfully from the terminal command line. I cannot, however, run them from the graphical file manager. Double-clicking the icon only opens the script in a text editor. Selecting Open With>Other Applications>Choose Applications does not provide an option for python 3.4, and the Add button to add python 3.4 to the context menu is grayed out and inactive. How can I enable myself to execute python 3 scripts from within the graphical login manager?

I am running OpenSUSE 13.2 Gnome 64-bit.

On Thu 21 May 2015 07:46:02 PM CDT, inkonstant wrote:

To run my own python 3 scripts I’ve taken these steps:

  • added the shebang to the top of the script
  • copied the script to /usr/local/bin
  • chmod +x on the copied script to make it executable
  • chown the script to my limited user account

This has enabled me to run scripts successfully from the terminal
command line. I cannot, however, run them from the graphical file
manager. Double-clicking the icon only opens the script in a text
editor. Selecting Open With>Other Applications>Choose Applications does
not provide an option for python 3.4, and the Add button to add python
3.4 to the context menu is grayed out and inactive. How can I enable
myself to execute python 3 scripts from within the graphical login
manager?

I am running OpenSUSE 13.2 Gnome 64-bit.

Hi
Create a desktop file and pop it in ~/.local/share/applications or if
wanting system wide /usr/share/applications.

If it’s just for your use placing in ~/bin would be enough…

For example here is one I have for Arduino sitting in ~/Desktop;


[Desktop Entry]
Name=Arduino
Comment=Arduino integration environment tool
Version=1.0
Icon=/home/malcolml/.icons/Arduino_Logo.svg
Exec=/data/makeblock/arduino-1.6.2/arduino
Type=Application
Terminal=false
Encoding=UTF-8
Categories=Development;IDE;

Desktop specs for openSUSE are here;
https://en.opensuse.org/openSUSE:Packaging_desktop_menu_categories


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.39-47-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

It didn’t work. I created a file named /usr/share/applications/python3.4.desktop and checked its ls -Falib to make sure the profile was correct. After I logged out and back in the listing still wasn’t in the context menu. I then did a hard reboot and same result. Here’s the file I created in case I screwed something up (since there are just no appropriate categories for what I’m trying to do here):

[Desktop Entry]
Name=Python3
Exec=/usr/bin/python3.4
Icon=
Terminal=False
Type=Aoplication
Encoding=utf-8
Categories=System;TrayApplication

Hi
No, Name is the name of your script or a friendly name, Exec is the script name/path in /usr/local/bin and Encoding is upper case.

It still didn’t work. I have given up and accepted that the Gnome developers have permanently screwed up Gnome by removing the option to add custom applications to the Open With context menu. It’s like Linux developers deliberately cripple everything Linux in order to force people to switch back to Windows. In Windows I can run the script just fine from any directory even without a shebang.

And I hate the stupid captcha every time I try to post a message because my vision is bad and the captcha is almost unreadable. I always have to try eight or nine times before I"m allowed to make a post.

Make an acccount here and log in then no more captcha

Windows uses the file extension to determine how to run a program. Can’t speak for Gnome but in KDE you can associate an extension with a program like in Windows so you can associate .py with python. The shabang tells the shell what program to run the file against.

Why aren’t you using something like PyDev to configure and switch between Python environments?

I’m not sure where the logic is to invoke a version of Python in the boot sequence.

Or, pls explain the entire picture what you’re trying to do (run a special service or other app that requires Python 3? But even in that case there is a “proper solution”)

TSU