我想将.py文件转换为可执行文件并在树莓派上运行。我安装了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)转换为可执行文件并在我的树莓派上运行它。
最佳答案
将 linux-32bits 重命名为 linux-32bits-arm 仍会生成 x86 文件。您需要编译自己的 linux-32bits-arm 引导加载程序。
在您的 PyInstaller 分发目录中运行:
cd bootloader
sudo python ./waf configure --no-lsb all
然后将整个 ../PyInstaller/bootloader/linux-32bits-arm 复制到您重命名该引导加载程序的目录
之后就应该可以正常工作了。
关于python - 如何在树莓派上运行可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35430043/