Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Raspberry pi上运行可执行文件_Python_Mono_Raspberry Pi_Pyinstaller - Fatal编程技术网

Python 如何在Raspberry pi上运行可执行文件

Python 如何在Raspberry pi上运行可执行文件,python,mono,raspberry-pi,pyinstaller,Python,Mono,Raspberry Pi,Pyinstaller,我想将.py文件转换为可执行文件并在raspberry pi上运行。我安装了pyinstaller sudo apt-get install pyinstaller sudo pyinstaller test.py 此命令用于创建test.spec文件和dist文件夹 cd dist/test 我得到了一个名为test的可执行文件。现在我想运行它 sudo ./test error: ./test: 1: ./test: Syntax error: "(" unexpected 我安装m

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

sudo apt-get install pyinstaller
sudo pyinstaller test.py
此命令用于创建test.spec文件和dist文件夹

cd dist/test
我得到了一个名为test的可执行文件。现在我想运行它

sudo ./test

error: ./test: 1: ./test: Syntax error: "(" unexpected
我安装mono

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引导加载程序

在PyInstaller分发目录中运行:

cd bootloader
sudo python ./waf configure --no-lsb all
然后将整个../PyInstaller/bootloader/linux-32bits-arm复制到您重命名该引导加载程序的目录中


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

您是否尝试了
chmod
?请尝试使用一个更简单的python脚本再现您的问题,并将其添加到您的问题中。另外:你的pyinstaller和mono版本是什么?是的,我使用sudo chmod u+x测试。但结果是samemy test.py只包含打印的“hello”。我使用的是python 2.7、pyinstaller 3.1和mono 3.2.8,正如我使用的是raspberry pi一样,我将pyinstaller引导加载程序的名称从linux-32bits更改为linux-32bits-armi不熟悉这个过程。请详细说明。cd引导加载程序是什么意思?它是cd/usr/local/lib/python2.7/dist-packages/PyInstaller/bootloader???我从lx终端发出命令这里编译器仍然是linux-64位和linux-32位知道我要做什么吗???从lx终端发出sudo python./waf configure--no lsb all error:cannot open./waf:no这样的文件这不是正确的目录,你必须从,解包后,它里面有一个带waf文件的文件夹bootloader谢谢你,wallycz,它很有用,现在我可以运行我的测试程序了。但是我的主程序(包含RPI.GPIO、Tkinter、mysql、PIL)没有运行。在第1行,我的python命令是import RPI.GPIO as GPIO,错误是:import error:没有名为RPI.GPIO的模块您安装了Python3的RPI.GPIO库吗
sudopip安装RPi.GPIO
,然后再次
sudopyinstaller./test.py
。它对我有用。。。