Exception loading builtin extension lens shading calibration

I started getting these errors, and no camera signal. It seems like this is happening after raspberrian patches. Running on a Pi 4 2GB. It was working earlier. From the error it seems like whatever value is being checked to verify that this is a Pi is not finding what it wants now. I have done:
sudo ofm update
sudo ofm upgrade
sudo ofm restart

Linux microscope 5.4.51-v7l+ #1326 SMP Fri Jul 17 10:51:18 BST 2020 armv7l

[MainThread] [ERROR] Exception loading builtin extension lens shading calibration:
Traceback (most recent call last):
File “/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/default_extensions/init.py”, line 10, in handle_extension_error
yield
File “/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/default_extensions/init.py”, line 28, in
from .picamera_autocalibrate import lst_extension_v2
File “/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/default_extensions/picamera_autocalibrate/init.py”, line 1, in
from .extension import lst_extension_v2
File “/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/default_extensions/picamera_autocalibrate/extension.py”, line 13, in
from .recalibrate_utils import (
File “/var/openflexure/application/openflexure-microscope-server/openflexure_microscope/api/default_extensions/picamera_autocalibrate/recalibrate_utils.py”, line 5, in
from picamera import PiCamera
File “/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/picamera/init.py”, line 89, in
from picamera.camera import PiCamera
File “/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/picamera/camera.py”, line 80, in
from RPi import GPIO
File “/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/RPi/GPIO/init.py”, line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

[2020-07-22 10:35:51,058] [MainThread] [INFO] Starting OpenFlexure Microscope Server…
[2020-07-22 10:36:33,138] [DummyThread-9] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,177] [DummyThread-10] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,298] [DummyThread-13] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,304] [DummyThread-9] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,309] [DummyThread-10] [INFO] Loading /var/openflexure/settings/microscope_configuration.json…
[2020-07-22 10:36:33,354] [DummyThread-10] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,363] [DummyThread-13] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,371] [DummyThread-10] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,399] [DummyThread-13] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,441] [DummyThread-9] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,592] [DummyThread-10] [INFO] Loading /var/openflexure/settings/microscope_configuration.json…
[2020-07-22 10:36:33,617] [DummyThread-14] [WARNING] GPU preview not implemented in mock camera
[2020-07-22 10:36:33,680] [DummyThread-12] [INFO] Loading /var/openflexure/settings/microscope_settings.json…
[2020-07-22 10:36:33,872] [DummyThread-15] [WARNING] GPU preview not implemented in mock camera
[2020-07-22 10:36:39,650] [DummyThread-16] [WARNING] GPU preview not implemented in mock camera
[2020-07-22 10:36:39,652] [DummyThread-17] [WARNING] GPU preview not implemented in mock camera
[2020-07-22 10:36:39,659] [DummyThread-18] [WARNING] GPU preview not implemented in mock camera

Hmm, this is very strange - it looks like the picamera python module isn’t able to load properly. The thing that is odd is that it looks like the module that’s failing is RPi._GPIO and I didn’t modify that one (the picamera module is not the official one, it’s a modified fork that adds some features). I suspect this is one to check out upstream - e.g. write a small Python program in a separate virtual environment that loads and runs the camera. If that works, it must be some difference between the forked and upstream versions of picamera.

If you’re happy enough with Python to try this, please do give it a go and maybe raise an issue on my picamera fork. If not, this is something for @jc2450 when he has a moment, I think.

I solved this by upgrading RPi.GPIO to 0.7.0 in the openflexure venv (it was 0.6.5).
The way I did it:
su openflexure-ws
source /var/openflexure/application/openflexure-microscope-
server/.venv/bin/activate
pip install -Iv RPi.GPIO==0.7.0
Test that no more error:
python
from RPi._GPIO import *
control+d
Restart ofm:
sudo ofm restart

1 Like