Raspberry Pi Zero 上的 Python 非法指令 [英] Python Illegal instruction on Raspberry Pi Zero

查看:34
本文介绍了Raspberry Pi Zero 上的 Python 非法指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行 python 脚本时,我得到 Illegal instructions 就是这样,它没有提供更多细节,所以我不知道发生了什么,有没有办法找出是什么导致了 Illegal instructions 错误?另外,我使用 sudo 运行代码我没有得到任何输出,程序只是退出.

更新:

我正在运行的脚本是来自 bluez 的 simple-agent 脚本:https://github.com/pauloborges/bluez/blob/master/测试/简单代理

另外,我像 @buratino 说的那样逐行运行,我在第二行遇到错误:

from gi.repository import GObject

解决方案

就像 @Notlikethat 说的,正在执行的代码是为不同的架构编译时会发生非法指令错误,Raspberry Pi 使用 ARM.

也就是说,我发现 GObject 似乎是导致问题的原因.无论如何,我卸载了我安装的所有蓝牙相关软件包,然后使用 raspbian 存储库重新安装它们,现在 Illegal Instruction 消失了,脚本正确执行.

为什么会这样?嗯,我有一个 Raspberry Pi Zero,这意味着我没有以太网端口,在我购买 WiFi 加密狗之前,我通过在我的计算机并将 .deb 存储在 SD 卡中,当然这意味着我必须手动检查我是否正在下载正确版本的软件包,我一定是在其中一个中搞砸了.

经验教训,永远不要尝试手动安装软件包,让 apt-get 完成所有工作!

When I try to run a python script I get Illegal instruction and that's it, it doesn't give any more details so I have no idea what's going on, is there a way to find out what is causing the Illegal instruction error? Also, I run the code using sudo I don't get any output, the program just exits.

UPDATE:

The script I'm running is the simple-agent script from bluez: https://github.com/pauloborges/bluez/blob/master/test/simple-agent

Also, I ran line by line like @buratino said and I got the error in the second line:

from gi.repository import GObject

解决方案

Like @Notlikethat said, the Illegal instruction error happens when the code being executed was compiled for a different architecture, Raspberry Pi uses ARM.

That said, I found out that GObject seemed to be causing the problem. Anyway, I uninstalled every bluetooth related package I had installed and reinstall them using the raspbian repository and now the Illegal instruction is gone and the script executes correctly.

Why did this happen? Well, I have a Raspberry Pi Zero which means I don't have an Ethernet port, before I bought a WiFi dongle I installed a few packages by downloading them on my computer and storing the .deb in the SD card, of course this means I have to manually check that I'm downloading the right version of the package, I must've messed up in one of them.

Lesson learned, never try to manually install packages, let apt-get do all the work!

这篇关于Raspberry Pi Zero 上的 Python 非法指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆