[英]pyinstaller no predefined compiler for raspberry pi
我想将myscript.py转换为可执行文件。 我正在使用覆盆子pi(raspbian)和python 2.7。
我发出以下命令
sudo pip install PyInstaller
sudo pyinstaller myscript.py
经过一些处理后,它会提供错误
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.
我上网建立编译器,但无法理解这个过程。 我怎么能解决这个问题?
编译bootloader的可疑路径对于您的平台是错误的
可以在这里论坛中提到这样做
cd /usr/local/lib/python2.7/dist-packages/PyInstaller/bootloader
sudo mv Linux-32bit Linux-32bit-arm
对于RPI,您需要获取bootloader ...您可以将pyinstaller v3.1.1克隆到您的rpi中同样的事情,在构建pyinstaller之后更改arm平台的目录名称
cd /path/to/pyinstaller/PyInstaller/bootloader
cp -R Linux-32bit Linux-32bit-arm
经过几个小时的搜索,我得到了这个工作。 答案很简单,但它分布在多个StackExchange答案和GitHub问题上。 我在本教程中将它全部放在一起,所以我为下一个可怜的灵魂节省了一些时间。
pip
使用不正确的架构运送PyInstaller。 你需要自己为ARM(Raspberry Pi)构建它。 1.构建引导程序
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
在这里你应该看到Linux-32bit-arm
和它内部的run
和run_d
2.检查引导加载程序
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
如果你看到上述内容,那么你到目前为止还是很好。 但是,如果你看到像ELF 32-bit LSB executable, Intel 80386
,这是错误的。
3.复制引导加载程序
如果您在一个venv
安装了带有pip
的venv
,那么就这样做吧
# 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/
如果您使用apt-get安装,请执行此操作
# !!! 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
问题
SystemError: objcopy Failure: objcopy: Unable to recognise the format of the input file `$FILE`
校验
`file dist/$FILE`
如果它没有说ELF 32-bit LSB executable, ARM [...]
,而是说Intel或x86,PyInstaller会尝试使用不正确的引导加载程序。 如果您执行了上述所有步骤,请尝试将Linux-32bit-arm
重命名为Linux-32bit
。 这似乎对这个用户有用
问题
gcc not found
解
sudo apt-get install build-essential
对于RPI,请首先克隆pyinstaller源代码 ,然后按照我的说明进行操作。
使用以下命令为您的操作系统创建引导加载程序:
python3.5 ./waf distclean all
在/usr/local/lib/python3.5/dist-package/PyInstaller/bootloader中创建Linux-32bit-arm子文件夹
cp pyinstaller/bootloader/build/debug/run_d /usr/local/lib/python3.5/dist-package/PyInstaller/bootloader/Linux-32bit-arm/
cp pyinstaller/bootloader/build/release/run /usr/local/lib/python3.5/dist-package/PyInstaller/bootloader/Linux-32bit-arm/
通过运行setup.py,我可以在运行Raspbian(第9.4版)的Raspberry Pi上安装和创建可执行文件。 安装的Python版本是3.5.3。
git clone https://github.com/pyinstaller/pyinstaller
sudo python3 setup.py install
之后,只需执行pyinstaller <source>.py
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.