Hi, I’m trying to get the Motorized Focus Camera (B0393) working on my Raspberry Pi 4 and I keep hitting the same error. I’m following the paper instruction manual and the online docs, but the motor control examples just won’t run. The camera itself works fine with libcamera, but anything that pulls in picamera2 blows up.
Running python FocuserExample.py -i 10 from /home/etscalsi/RaspberryPi/Motorized_Focus_Camera/python/ gives me this:
Traceback (most recent call last):
File "/home/etscalsi/RaspberryPi/Motorized_Focus_Camera/python/FocuserExample.py", line 27, in <module>
from RpiCamera import Camera
File "/home/etscalsi/RaspberryPi/Motorized_Focus_Camera/python/RpiCamera.py", line 10, in <module>
from picamera2 import Picamera2, Preview
File "/usr/local/lib/python3.9/dist-packages/picamera2/__init__.py", line 1, in <module>
from .configuration import CameraConfiguration, StreamConfiguration
File "/usr/local/lib/python3.9/dist-packages/picamera2/configuration.py", line 1, in <module>
from .controls import Controls
File "/usr/local/lib/python3.9/dist-packages/picamera2/controls.py", line 4, in <module>
from libcamera import ControlType, Size, Rectangle
ImportError: cannot import name 'ControlType' from 'libcamera' (/home/etscalsi/.local/lib/python3.9/site-packages/libcamera.cpython-39-arm-linux-gnueabihf.so)
Setup: Raspberry Pi 4, latest Raspberry Pi OS (32-bit version). picamera2 is at /usr/local/lib/python3.9/dist-packages/picamera2, and libcamera is showing up at /home/etscalsi/.local/lib/python3.9/site-packages/libcamera.cpython-39-arm-linux-gnueabihf.so which seems a bit odd to me?
I’ve reinstalled the OS and followed the instructions several times already and still get the same error. Also, does the OS version matter — I installed the 32-bit version, should it have been 64-bit? I’m trying to get this module working to assess achievable image quality for a new IOT product. Bug report files attached.
Hi, thanks for the very detailed report. First thing: don’t worry about the architecture — we support both 32-bit and 64-bit, so the fact you installed the 32-bit OS is not the cause here.
Let’s get a proper diagnostic. Please reboot the board first, then run:
That produces an arducam-bug-report.txt in the current directory. Attach that file and we’ll dig in. Also, can you tell me what picamera2 version you have installed? sudo pip3 list | grep picamera2 will show it.
I ran that command and rebooted the board, but I still get the identical error:
ImportError: cannot import name 'ControlType' from 'libcamera' (/home/etscalsi/.local/lib/python3.9/site-packages/libcamera.cpython-39-arm-linux-gnueabihf.so)
And just to confirm, pip still reports picamera2 0.3.3 after the install:
That output tells me something is messing with libcamera on your device. Quick question — did you ever compile libcamera manually, or install our previous libcamera-python library at some point? A leftover build like that would shadow the correct one, and it would also explain why the pip downgrade isn’t sticking — your local .so in ~/.local is being picked up instead.
Tried that too, still the same error. Honestly, I started with a clean build of my RPi 4 — the only thing I’ve done on it is try to install the software required for this camera, so I’m not sure where a manual libcamera would even have come from.
Could you send me the instructions to install the camera again from scratch? I’ll replace the OS so it’s completely new and try yet again. Current state:
Important part is to not mix a pip-installed libcamera with the apt/pivariety one — keep only the apt stack for libcamera and pin picamera2. Give that a go and let us know how you get on.
Good news — I rebuilt the RPi OS again today and followed a couple of different installation instructions, and it now appears to be working. The ImportError is gone and the focuser example runs. Thank you for your help — I may have additional questions soon once I start testing image quality.
Great to hear it’s up and running. To recap where this landed: the ControlType ImportError came down to the picamera2/libcamera mix on the device — a stale libcamera in ~/.local was conflicting with the APT/pivariety libcamera, and picamera2 wouldn’t drop below 0.3.3 with that conflict present (which is why the pip downgrade kept reporting 0.3.3). A clean OS image, the pivariety libcamera packages, and a pinned picamera2 0.3.2 sorted it out.
If you ever see the same import error again after an update, first check sudo pip3 list | grep picamera2 and make sure no stray libcamera is installed under ~/.local. Post back whenever you start your image-quality testing.