Python Forum
Illegal instruction? working code for months? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Illegal instruction? working code for months? (/thread-34489.html)



Illegal instruction? working code for months? - korenron - Aug-04-2021

Hello ,
strange issue
I have a PI3 working with a python code that show data on I2C Oled display.
this code and PI works great for the last 6 months~
today I saw it's stop working (showing data - I reboot the the pi
and the app didn't boot

when I try to run the code manually , I got this error:
[email protected]:~ $ python3 /home/pi/Display.py
Illegal instruction
even when I change the code and put syntax errors - I still got this error

what is wrong? and mpre importent what happand?

*** no one it using this pi , I didn't run update\upgrade for 6 months now


RE: Illegal instruction? working code for months? - bowlofred - Aug-04-2021

"illegal instruction" means the pi is trying to run code that isn't correct for that machine. This isn't a problem with your python script, it's a problem with the actual python executable or one of the modules imported by your script. You might be able to tell just by seeing if python3 runs on its own. Does python3 -c "print('ok')" work or get the same error? If that works, you might be able to find what module is causing the problem.

Unfortunately if python3 is broken, sorting that out is going to be something on the Pi side. Could be you need to update some packages, could be it would be better to restart from scratch. We can't tell what happened. Maybe something updated some packages from the wrong repo. Maybe the SD card filesystem became corrupted from a powerdown. Might need to ask in a Pi forum.


RE: Illegal instruction? working code for months? - korenron - Aug-05-2021

when I run the command
it's working
[email protected]:~ $ python3 -c "print('ok')"
ok
so now try to check all the imports I have in the code ? to see which one casue the problem ?
then reinstall it ?


RE: Illegal instruction? working code for months? - DeaD_EyE - Aug-05-2021

Looks like a C-Extension is crashing. What does Display.py import?


RE: Illegal instruction? working code for months? - korenron - Aug-05-2021

this is very strange......

I have created a file with all the import:
import time
from datetime import datetime
import Adafruit_SSD1306
import subprocess
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont

import os
import sys
import random
from random import randint

import RPi.GPIO as GPIO 
run it , didn't get any error

then I try to run my working full code
and it works ....

how could it be ?
I didn't change anything \ didn't reboot the pi since yesterday \ didn't run update&&upgrade