I have a simple python program and I want an executable version (for Ubuntu Linux) of this program to avoid running it in the terminal with python myprogram.py.

How can I do that ?

There is no need to. You can mark the file as executable using

chmod +x filename

Make sure it has a shebang line in the first line:

#!/usr/bin/env python

And your linux should be able to understand that this file must be interpreted with python. It can then be ‘executed’ as

./myprogram.py

As various others have already pointed out you can add the shebang to the top of your file

#!/usr/bin/python or #!/usr/bin/env python

and add execution permissions chmod +x program.py

allowing you to run your module with ./program.py

Another option is to install it the pythonic way with setuptools. Create yourself a setup.py and put this in it:

from setuptools import setup

setup(
    name="Program",
    version = '0.1',
    description = 'An example of an installable program',
    author="ghickman",
    url="",
    license="MIT",
    packages = ['program'],
    entry_points = {'console_scripts': ['prog = program.program',],},
)

This assumes you’ve got a package called program and within that, a file called program.py with a method called main(). To install this way run setup.py like this

python setup.py install

This will install it to your platforms site-packages directory and create a console script called prog. You can then run prog from your terminal.

A good resource for more information on setup.py is this site: http://mxm-mad-science.blogspot.com/2008/02/python-eggs-simple-introduction.html

You can try using a module like cxfreeze

At the top op your python program add:

#!/usr/bin/python

I know the easiest, exact and the best solution. I had the same problem like you but now, I can run my Python/Tkinter(GUI) program with its icon.

As we create .bat files on Windows, we can also create equivalent the .bat files easily in Linux too. Thanks to this file, that, we can start our programs without terminal even if it needs to get command on terminal to start (like Python programs) with double click to its icon (really .png icon 🙂 ) or we can write commands to facilitate our works.
So, how is this going to happen ?

For example, if we want to run our .py program, we just need to write this command to terminal :

python3 locationOfPyFile

So if we create a file that can automatically run this command, problem would be solved. In addition to that, you can have your own icon and even you don’t have to open terminal !

Check this article : Run Commands From It’s Icon (Easiest Way)