On Ubuntu an executable created with Pyinstaller d

2020-08-03 04:33发布

问题:

I am on ubuntu 16.04. I am trying to make an executable from my python script (fez.py) using pyinstaller using pyinstaller --onefile fez.py.

The executable gets built without any error. I get the two folders dist and build with the .exe file in dist. I get the fez.spec file too. But when I try to run the executable nothing seems to happen.

My question is:

Is there a problem with the pyinstaller process to create the executable that doesn't get displayed as an error OR is there a problem with my ubuntu that it can't run the executable? Whichever is the reason how to run my executable?

NB: I am well versed with the fact that pyinstaller is OS specific i.e. for an executable to work on ubuntu it should be prepared on ubuntu itself and that is exactly what I have done. I have used the pyinstaller command on ubuntu. This also rules out the fact that I should install wine or something else of that sort as wine is required to execute windows executables on ubuntu. (Files with .exe extension) The executable I am making using pyinstaller on ubuntu specifically builds executables for ubuntu. (In properties they show application\x-executable)

EDIT: To run the executable I had to first change the permission to allow as executable. Then I had to run from the terminal. But is there no way to run it using double clicks.

回答1:

To execute the fez executable from terminal, go to the folder containing the executable (i.e: /home/user/dist folder) and run the below command in terminal (here the executable is called fez is the name of the executable):

~/dist$ ./fez

After executing the command if your script has any print statements then the statements are displayed in the terminal. Even if you executable or script has any errors, they are displayed in terminal.



回答2:

I don't know exactly how to do it... but I believe you can create a .desktop file that sets parameters like terminal = [true/false] and command = "/path/to/executable" or something like that. Then you can double click the .desktop file and it will execute your program. I've never tried this... just read about it a while back. Maybe google .desktop files and see if that leads you anywhere...