Showing results for 
Search instead for 
Did you mean: 

Can I use pyinstaller on Ubuntu to bundle Python code into an executable file and run it on STM32?

Associate II



I am a newcomer to embedded systems. I have a STM32MP157D-DK1 and I'm planning to develop some python applications to run on the A7 processor. I am encountering some issues.

1. I created a simple web application using Python on Ubuntu. (python module: Flask)
2. I confirmed that it can be executed successfully.
3. I bundled it into a single executable file using pyinstaller (PC $> pyinstaller --onefile).
4. I verified that the executable file can be used properly.
5. I transferred the file to an STM32 (starter kit).
6. When I tried to execute the file, an error occurred.
Error Message:
./app: line 1: syntax error: unexpected ")"

Other experiments:
I try to execute python source code directly on STM32, there is no problem.
I try to bundle python code into a single executable on STM32, but can't install pyinstaller. (pip3 install pyinstaller)

Thanks for your support,

Jean-Marc B
ST Employee

Hi @Ken_102633 

The app you created with pyinstaller from your PC running ubuntu is compiled for an architecture compatible with your PC (most probably x86_64). However, STM32MP15 boards rely on a ARM architecture hence can't run x86_64 app. That explains the error you got in your 6th step.

Then, installing pyinstaller from pip3 shows errors as some build dependencies are not available such as a gcc toolchain. To bypass these dependencies, you need to build your own distribution and setup your own repository (please refer to )

Once your repository is activated, install the package group core-buildessential:


root@stm32mp1:~# apt-get update
root@stm32mp1:~# apt-get install packagegroup-core-buildessential
root@stm32mp1:~# apt-get install ldd


 You can now install pyinstaller with the following command:


root@stm32mp1:~# env PYI_STATIC_ZLIB=1 pip3 install pyinstaller


Then try to build your app.

Best regards,


Thank you so much @Jean-Marc B , the steps listed here helped to install and work with pyinstaller on stm device!