如何 运行 Raspberry pi 上的可执行文件

How to Run an executable file on Raspberry pi

我想将 .py 文件转换为可执行文件,运行 raspberry pi。我安装了 pyinstaller

sudo apt-get install pyinstaller
sudo pyinstaller test.py

此命令创建一个 test.spec 文件和 dist 文件夹。

cd dist/test

我有一个名为 test.txt 的可执行文件。现在我想运行它

sudo ./test

error: ./test: 1: ./test: Syntax error: "(" unexpected

我安装单声道

sudo apt-get install mono-complete
sudo mono test.exe

错误:

no such file on the directory

那我用

sudo mono test

错误显示:

cannot open assembly'test':file does not contain a valid CIL image

我该如何解决我的问题。我想将我的代码(闲置时编写的 .py)转换为可执行文件并 运行 它在我的 raspberry pi.

将 linux-32bits 重命名为 linux-32bits-arm 仍会生成 x86 文件。您需要编译自己的 linux-32bits-arm bootloader。

在您的 PyInstaller 分发目录中 运行:

cd bootloader
sudo python ./waf configure --no-lsb all

然后将整个 ../PyInstaller/bootloader/linux-32bits-arm 复制到您重命名引导加载程序的目录

之后它应该可以正常工作了。