You’re right that these are two separate issues: the libcamera._libcamera import problem and the tensor‑size error. Let’s untangle them.
For the libcamera / Python version problem: the Sony Aitrios modlib stack is only tested against Python ≤3.11, and our IMX500 guide was validated on Raspberry Pi OS Bookworm with Python 3.11 as the system Python, as described in the Sony IMX500 export guide. On your image with Python 3.13 as the default, the libcamera Python bindings are built for 3.13, so a hand‑compiled 3.11 interpreter has no matching libcamera._libcamera extension, which is exactly the error you’re seeing.
Practically, the reliable path today is to run your IMX500 runtime scripts on a Raspberry Pi OS image where Python 3.11 is the system version (e.g. the standard Bookworm image Sony and Raspberry Pi document), and install only imx500-all plus the aitrios-rpi-application-module-library into a virtual environment. Mixing a 3.13 system with a custom 3.11 almost always leads to the binding mismatch you hit; there isn’t a clean workaround unless Raspberry Pi ship libcamera bindings for both versions.
Once you’re on a 3.11‑based OS and the Aitrios examples run cleanly, if you still see the tensor mismatch error, please share the exact yolo export command and model you used. IMX export in Ultralytics uses a fixed Sony MCT config for supported models (YOLOv8n and YOLO11n detect/pose) via model.export(format="imx", data=...), as shown in the IMX500 usage examples, and that should avoid the 708 vs 712 tensor‑length issue you and the OP are seeing.