1

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

Community
  • 1
  • 1
redsalt
  • 1,519
  • 4
  • 20
  • 28
  • Have you tried running the instructions of the script in an interpreter? – buratino Jun 10 '16 at 12:36
  • I ran it two ways: `./script` and `python script`, same result. – redsalt Jun 10 '16 at 12:39
  • I should have been more clear. Try running `/usr/bin/python3` (or whichever version you want to run). When the interpreter is launched, you can enter and test the instructions of your script one by one. If that does not yield any results, maybe you could add the script to your question. – buratino Jun 10 '16 at 12:44
  • are you sure it is a python script ? – daouzli Jun 10 '16 at 12:44
  • It's the simple-agent script from bluez: https://github.com/pauloborges/bluez/blob/master/test/simple-agent – redsalt Jun 10 '16 at 12:47
  • Most likely either your script pulls in some module involving native code containing unsupported (i.e. ARMv7) instructions, or you have an inappropriate (i.e. ARMv7) build of the Python interpreter itself. Or maybe you have a crazy kernel with floating-point support turned off. Without knowing any details it's kinda hard to say. – Notlikethat Jun 10 '16 at 12:47

1 Answers1

1

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!

Community
  • 1
  • 1
redsalt
  • 1,519
  • 4
  • 20
  • 28
  • 2
    There are often times for me where manually downloading and installing packages is preferred over using `apt-get`. A better lesson to learn, I think, is to be sure about what you're downloading and installing. – buratino Jun 13 '16 at 10:51