Linux: How to run pyinstaller binary in the file manager?

Binary generated from pyinstaller

From the terminal, I can run ./hello and my Python binary runs fine… but how can I get it to run from the file manager?

I did already set permission of binary to executable, doubleclick on the icon does not execute

Running LMDE6 with Nemo.

Thanks,
Andrew

well, first let’s get terminology straight. Unless you went out of your way to compile a binary executable from python, python doesn’t have binaries.

Now, to your question. It depends on what kind of file this is. Basically the first thing you do is set permissions to your file to u+x (chmod u+x). Then, if you don’t get an option in the drop-down menu to execute it, go to open with and add python to the list. It will launch the script from your file manager. Oh, and you probably want to have the shebang declaration for python interpreter in that file.

I am sorry, I neglected to post relevant information.

binary was compiled via pyinstaller.

so, what does it supposed to do? just print something on the terminal? How did you build it?

Yes, it is just a Hello World

pyinstaller cli-hello.py --name hello --onefile

Py:
#!/usr/bin/env python3
print(“hello”)
input(“Press Enter to continue…”)

The Python script you have there is already executable. Just chmod it and use it as-is. There is no need for pyinstaller.

Understood. I did that with success, but I was playing with pyinstaller and the binary did not execute in the same manor (doubleclick from file manager). I am just trying to learn pyinstaller.

Thanks Chris.

so, console scripts like these are always weird when you launch them from the file manager. Normally you don’t actually want to launch them like this. Basically the console often just isn’t displayed for them visually for you. So you script might actually work, but you won’t see it.
If you want to play around and try it, just use something like this:

import tkinter as tk

root = tk.Tk()

canvas = tk.Canvas(root, width=300, height=300)
canvas.pack()


def hello():
    label = tk.Label(
        root, text="Hello World!", fg="blue", font=("Arial", 18, "bold")
    )
    canvas.create_window(150, 200, window=label)


button = tk.Button(text="Click Me", command=hello, bg="brown", fg="white")
canvas.create_window(150, 150, window=button)

root.mainloop()

it will basically make a gui form for you with hellow world. Run pyinstaller on it and click away.

Why though? It achieves something that is completely unnecessary on Linux systems, where it’s easy to depend on a pre-existing installation of Python. Don’t bother with it; it adds a huge amount of completely unnecessary complexity to a task that is adequately solved by a shebang.

If you’re trying to learn pyinstaller so you can deploy to Windows, then sure, but being able to launch from the Linux file manager is irrelevant to that. (Also, there are other ways of deploying to Windows too.)

Setting .py to executable and double clicking to run script in the file manager appears to work for a CLI, however with either TK or PySimpleGUI the app does not run (AFAIK?) as I do not see the forum.

I am still learning, thanks.

when you run just a bare python script by double clicking, you just have to make sure all libraries are installed and available system-wide. It will work with no issues if that is done. Pyinstaller makes it so you don’t need to to have them properly set up, but in return it makes your binaries hundreds of megabytes in size for something trivial.

First find out what happens when you run these programs from the terminal. When they fail you will see errors messages that will help you fix problems.

Once the programs work without problem from the germinal then try from the file manager.