Skip to content
Advertisement

How to build a Tkinter GUI in linux like exe in window?

I worote some Tkinter script in Linux,everytime I use “python script.py” to run it from terminal, but in windows,I can use pyinstaller to build an EXE file, then double click the GUI will run. How do I do in linux to build an “exe” file then can click it will run instead of “python script.py”?

pyinstaller

Advertisement

Answer

In Linux you can add shebang (#!) in first line of script

with full path to python

#!/usr/bin/python

or more popular (because different Linux may have Python in different folder)

#!/usr/bin/env python 

And set it executable

chmod +x script.py 

and then you can run it as any other program by clicking or writhing in console script.py without python.

System will use information from shebang to run it with Python.

You can even remove extension or set different extension – even .jpg – and it should run it with Python.


The same way you can create executable script with Bash, Perl, Ruby, ect. or even in PHP.


To find path to python, perl, etc

which python

which perl

# = she , ! = bang, #! = shebang

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement