How to Get Pyinstaller to Working on Ubuntu

How can I get pyinstaller to working on Ubuntu?

First you need to find where pip installed PyInstaller:

sudo find / -name pyinstaller

Then you can either run it using the full path or add it to your .bashrc file. To add to .bashrc, create the following line or add your path to any existing "export PATH=" line in your .bashrc (found in your home directory):

export PATH="/path/to/pyinstaller:$PATH"

Save that file and logout/login to have it take effect.

To make the path available to all users, add it to your /etc/environment file (must be sudo edited).

pyinstaller command not found

You can use the following command if you do not want to create additional python file.

python -m PyInstaller myscript.py

Unable to install pyinstaller in Ubuntu 16 with Python3.5

Okay I think I have finally managed to run pyinstaller on ubuntu16.

I am not sure if its the issue with Ubuntu16 or python3.5, but we need to upgrade the python version. So I first installed python3.6 using below commands:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6

After the installation, I made sure that running python3 is invoking the python3.6 and not python3.5:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

sudo update-alternatives --config python3

After this if you type in python3, it should launch python3.6.

Once this is all done, just upgrade pip :

sudo python3 -m pip install --upgrade pip

after that you can install pyinstaller:

sudo pip3 install pyinstaller

also run this command:

sudo apt-get install python3.6-dev 

otherwise you will get python lib not found error in pyinstaller build

and it will install and work fine.

I think pyinstaller is not working with python3.5 as this python version is also deprecated. So we need to upgrade the python version. So if any one is on ubuntu16 which has python3.5 as default, just upgrade your python version.

On Ubuntu an executable created with Pyinstaller doesn't run

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:

  • GCUL.RUN (The PyInstaller single file)
  • run-mime-type.xml
  • enable-run-mime-type.sh (ran as sudo)

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.

Not able to run Pyinstaller executable on Linux

Got it running by typing the relative path dist/hello in terminal

Trouble using PyInstaller in Ubuntu

Try this

pyinstaller -F --clean code.py --hidden-import='tesserocr.PyTessBaseAPI' --hidden-import='ocrmypdf'

Executables made with pyinstaller not working

After a lot more tinkering I finally have a working exe.
I used -D to make a directory rather than the --onefile as that doesn't work. It makes an exe that doesn't work. Windows complains that it can't unpack the app.
The exe that is inside the dist directory works on Windows 8.1 and Windows 10. Didn't test on Win 7.

I also included the png and ico files and used a clean env with python 3.8 instead of my working env with 3.7 installed. I'm not sure if any of these things made a difference but if anyone else is looking for an answer, this might help.

My final command:
pyinstaller -y -D -w -i "FULL PATH TO ICON .ico" --add-data "FULL PATH TO IMAGE .png";"." "FULL PATH TO PY FILE /app.py"



Related Topics



Leave a reply



Submit