Can I have a .desktop Launcher for both Python2 and Python3 depending on version installed?

Posted by Takkat on Ask Ubuntu See other posts from Ask Ubuntu or by Takkat
Published on 2012-11-30T09:09:12Z Indexed on 2012/11/30 11:22 UTC
Read the original article Hit count: 346

After very few issues only I moved my application from Python2 to Python3 making sure it will still run with Python 2.7, and hence has python >= 2.7 as dependency only.

This was mainly done because Python3, and some dependencies are not installed in a default 12.04 LTS, and I do not want my users to have to install all Python3 only to run my script.

When I create an appname.desktop launcher I now need to decide if it starts my application using Python2, or Python3 like

EXEC=python /path/app.py
EXEC=python3 /path/app.py

But what I would like it to do is to

  1. Launch the application with the Python3 interpreter if Python3 is installed.
  2. Otherwise use Python2 if Python3 is not installed.

How can this be done? Do I need to tell it in my package installation script, or can I have a launcher which can handle both (in case people install Python3 after they had installed my script)?

© Ask Ubuntu or respective owner

Related posts about launcher

Related posts about application-development