Full Tutorial
After many hours of searching, I got this working. The answer is straightforward, but it is spread across multiple StackExchange answers and GitHub Issues. I put it all together in this tutorial, so I save some hours for the next poor soul.
Key Takeaways
pip
ships PyInstaller with the incorrect architectures. You need to build it yourself for ARM (Raspberry Pi).
Step by Step
1. Build the bootloader
git clone https://github.com/pyinstaller/pyinstaller
# Alternatively download the zip from https://github.com/pyinstaller/pyinstaller/releases
cd pyinstaller/bootloader
python ./waf distclean all # or python3
cd ../PyInstaller/bootloader/
ls
Here you should see Linux-32bit-arm
and inside of it run
and run_d
2. Check the bootloader
file Linux-32bit-arm/run
run: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=a01c65d74d7d8b483800154dcdd4a5d2aad95d5b, stripped
If you see the above, you are good so far. However, if you see something like ELF 32-bit LSB executable, Intel 80386
, that is wrong.
3. Copy the bootloader
If you installed PyInstaller with pip
inside a venv
, then do this
# Replace ${CLONED_PYINSTALLER_PATH} with the path where you git cloned above
# Replace ${PATH_TO_YOUR_PROJECT} with the path to your project (where you have the venv)
cp -r ${CLONED_PYINSTALLER_PATH}/PyInstaller/bootloader/Linux-32bit-arm ${PATH_TO_YOUR_PROJECT}/venv/lib/python3.5/site-packages/PyInstaller/bootloader/
If you installed with apt-get, then do this
# !!! Replace python3.5 with your version
cp -r ${CLONED_PYINSTALLER_PATH}/PyInstaller/bootloader/Linux-32bit-arm /usr/local/lib/python3.5/dist-packages/PyInstaller/bootloader
Debugging
Issue
SystemError: objcopy Failure: objcopy: Unable to recognise the format of the input file `$FILE`
Check
`file dist/$FILE`
If it does not say ELF 32-bit LSB executable, ARM [...]
, but instead says Intel or x86, the PyInstaller tries to use the incorrect bootloader. If you executed all steps above, try renaming the Linux-32bit-arm
to just Linux-32bit
. That seems to have worked for this user
Issue
gcc not found
Solution
sudo apt-get install build-essential