1

I am running a pyenv with 3.10.5 for a RPi 4 b. RPi OS version if important:

pi@raspberrypi:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
...

The pyenv was simply the solution I could find for running python3.10 with a bit of ease on RPi.

I have a personal script camera_profiles.py that depends on Picamera2, and when I call it:

  File "/home/pi/MYPATH/camera_profiles.py", line 8, in <module>
    from picamera2 import Picamera2
  File "/home/pi/.pyenv/versions/3.10.5/lib/python3.10/site-packages/picamera2/__init__.py", line 1, in <module>
    from .picamera2 import Picamera2, Preview
  File "/home/pi/.pyenv/versions/3.10.5/lib/python3.10/site-packages/picamera2/picamera2.py", line 10, in <module>
    import libcamera
ModuleNotFoundError: No module named 'libcamera'

So I need libcamera as a dependency for picamera2, however pip install libcamera finds nothing.

The following link shows how to build libcamera, but I am unsure how this relates to usage as a module within pyenv. I'm also fairly certain my libcamera is preinstalled and works because of the following command working:

pi@raspberrypi:~ $ libcamera-hello -t 1 --nopreview
[0:09:50.914967732] [3438]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3544-22656360
[0:09:50.980574004] [3439]  WARN RPI raspberrypi.cpp:1241 Mismatch between Unicam and CamHelper for embedded data usage! 
[0:09:50.981300155] [3439]  INFO RPI raspberrypi.cpp:1356 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media2 and ISP device /dev/media0
[0:09:50.982164044] [3438]  INFO Camera camera.cpp:1029 configuring streams: (0) 1640x1232-YUV420
[0:09:50.982681847] [3439]  INFO RPI raspberrypi.cpp:760 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 1640x1232-SBGGR10_1X10 - Selected u                       nicam format: 1640x1232-pBAA

.. So I don't imagine installing from source will help me with this issue, but then how do I actually give picamera2 its libcamera dependency?

3
  • pip installs from precompiled wheels and AFAIK these are only built for the supported OS i.e. python 5, 7, 9. Other versions SHOULD built from source (assuming you have installed all dependencies).
    – Milliways
    Jul 2, 2022 at 23:15
  • Yes, I think you're right. So, when I pip install most packages while in pyenv3.10.5 it takes a long time to complete, perhaps that's because the prebuilts do not exist for 3.10.5 and it instead fetches the source, and then builds? I also had to build Scipy and seemingly Pillows from source. I don't think building libcamera automatically makes a wrapper module for python, though, looking a the few resources there are about the topic on the net.
    – Boooke
    Jul 3, 2022 at 11:23
  • Does this help? libcamera.org/getting-started.html Sep 29, 2022 at 9:09

1 Answer 1

2

Install this. sudo apt install -y python3-libcamera python3-kms++2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.