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.
I came across this issue, and I know this is an old post, but since it seems relevant and the first return in google for my problem I'll add since I spent a bit of time on this. The issue is that most files that don't have an extension are treated as text files, or some other MIME-Type, even if they are marked as executable. Running from the shell is one workaround but this is rather clunky. Here is my takeaway and my solution. I don't think Linux has any sort of "this is an executable" extension so if you want your GUI (eg gnome or whatever) to see the file as an application/executable file you have to set the mime type for that type of file. For me what I did was register .run as an executable mime-type. I have a .xml file that is used to register the new mime-type and then a .sh script that I can share with friends to do the same.
So I have three files:
And here are the contents of the .xml and .sh file. Once this is done, I can double click on the binary just like I would in windows and it opens.
run-mime-type.xml
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="application/x-executable">
<comment>Executable Binary File</comment>
<comment xml:lang="en">English</comment>
<glob pattern="*.run"/>
</mime-type>
</mime-info>
enable-run-mime-type.sh
#!/bin/bash
FILE=/usr/share/mime/packages/run-mime-type.xml
if test -f "$FILE"
then
echo "$FILE already found, aborting!"
else
cp run-mime-type.xml /usr/share/mime/packages
update-mime-database /usr/share/mime
fi
if test -f "$FILE"
then
echo "$FILE copied, updating MIME-Type database..."
echo "MIME-Type database has been updated!"
else
echo "$FILE not found, something went wrong..."
fi
Depending on your system you might have to change some path's but I think this would work for any Ubuntu-based OS running a Gnome variant, possibly others as well. What I am doing is copying the mime-type configuration .xml to the directory used to register mime-types and then updating the mime database.
Hope that helps someone.