# Exception loading builtin extension lens shading calibration

**URL:** <https://openflexure.discourse.group/t/exception-loading-builtin-extension-lens-shading-calibration/132>\
**Category:** Request Help\
**Created:** [28 July 2020 01:49 UTC](https://openflexure.discourse.group/t/exception-loading-builtin-extension-lens-shading-calibration/132 "2020-07-28T01:49:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vthyng](https://yyz2.discourse-cdn.com/free1/user_avatar/openflexure.discourse.group/vthyng/32/160_2.png) [@vthyng](https://openflexure.discourse.group/u/vthyng)\
**Post date:** [28 July 2020 01:49 UTC](https://openflexure.discourse.group/t/exception-loading-builtin-extension-lens-shading-calibration/132/1 "2020-07-28T01:49:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![r.w.bowman](https://yyz2.discourse-cdn.com/free1/user_avatar/openflexure.discourse.group/r.w.bowman/32/15_2.png) [@r.w.bowman](https://openflexure.discourse.group/u/r.w.bowman)\
**Post date:** [28 July 2020 07:22 UTC](https://openflexure.discourse.group/t/exception-loading-builtin-extension-lens-shading-calibration/132/2 "2020-07-28T07:22:16Z")

</div>

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](https://github.com/rwb27/picamera/issues). If not, this is something for @jc2450 when he has a moment, I think.

---

<div class="post-metadata">

**Author:** ![vthyng](https://yyz2.discourse-cdn.com/free1/user_avatar/openflexure.discourse.group/vthyng/32/160_2.png) [@vthyng](https://openflexure.discourse.group/u/vthyng)\
**Post date:** [2 August 2020 19:24 UTC](https://openflexure.discourse.group/t/exception-loading-builtin-extension-lens-shading-calibration/132/3 "2020-08-02T19:24:10Z")

</div>

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
