Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyinstaller no predefined compiler for raspberry pi

I want to convert myscript.py to a exexutable file. i am using raspberry pi(raspbian) and python 2.7.

I am issuing the following command

sudo pip install PyInstaller
sudo pyinstaller myscript.py

after some processing it provides an error

Fatal error: PyInstaller does not include a pre-compiled bootloader for your
platform. See <http://pythonhosted.org/PyInstaller/#building-the-bootloader>
for more details and instructions how to build the bootloader.

i go online to build compiler but could not understand the process. how could i solve this problem?

like image 382
user007 Avatar asked Jan 28 '16 09:01

user007


People also ask

Does PyInstaller work on Raspberry Pi?

First, I have successfully installed PyInstaller on my Raspberry using pip -> "sudo pip install pyinstaller", and after I compiled one of my files that uses Python2. 7 using "sudo pyinstaller --onefile my_file.py". The result is great and everything worked.

Why my PyInstaller is not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Does PyInstaller include all dependencies?

PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules. PyInstaller reads a Python script written by you.

Does PyInstaller work with libraries?

pip will install PyInstaller's dependencies along with a new command: pyinstaller . PyInstaller can be imported in your Python code and used as a library, but you'll likely only use it as a CLI tool. You'll use the library interface if you create your own hook files.

Does pyinstaller support Raspbian on Raspberry Pi ARM core?

But a google search revealed that pip install installes the wrong type of requirements. My project needs pygame module to work and also imports time, random and copy modules. The project is also spread across many files. Pyinstaller supports Linux but does it support raspbian on raspberry pi ARM core.

How does pyinstaller work?

PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally in a single executable file.

How do I install pyinstaller on Windows?

PyInstaller is available on PyPI. You can install it through pip: tinyaes 1.0+ (only if using bytecode encryption). Instead of installing tinyaes, pip install pyinstaller [encryption] instead. PyInstaller should work on Windows 7 or newer, but we only officially support Windows 8+.

Why won't pyinstaller run on linux-32bit-arm?

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.


1 Answers

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

like image 157
Andrei Cioara Avatar answered Sep 21 '22 00:09

Andrei Cioara