# Picamera not working as expected

**URL:** <https://forums.balena.io/t/picamera-not-working-as-expected/5672>\
**Category:** balenaOS\
**Tags:** raspberrypizero\
**Created:** [March 19, 2019, 10:19pm UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672 "2019-03-19T22:19:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nelson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nelson/32/1303_2.png) [@nelson](https://forums.balena.io/u/nelson)\
**Post date:** [March 19, 2019, 10:19pm UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672/1 "2019-03-19T22:19:14Z")

</div>

Hi,

I have been trying to get the rpi camera to work but it seems there’s something wrong with the `io.balena.features.kernel-modules` label. These are my Dockerfile and docker-compose file:

**docker-compose.yml**

```
version: '2.1'

services:
  picture:
build: .
restart: always
privileged: true
labels:
  io.balena.features.kernel-modules: '1'
  io.balena.features.dbus: '1'

```

**Dockerfile**

```
FROM balenalib/raspberry-pi-alpine-python:3.7-3.8

RUN pip install -U pip \
    && READTHEDOCS=True pip install --no-cache-dir picamera

WORKDIR /src
COPY . .
CMD modprobe v4l2_common && python test.py

```

My `test.py` file just imports the `picamera` module.

This will always result in the following error:

```
19.03.19 23:11:12 (+0100) test-image Traceback (most recent call last):
19.03.19 23:11:12 (+0100) test-image File "sample.py", line 2, in <module>
19.03.19 23:11:12 (+0100) test-image import picamera
19.03.19 23:11:12 (+0100) test-image File "/usr/local/lib/python2.7/site-packages/picamera/ __init__.py", line 72, in <module>
19.03.19 23:11:12 (+0100) test-image from picamera.exc import (
19.03.19 23:11:12 (+0100) test-image File "/usr/local/lib/python2.7/site-packages/picamera/exc.py", line 41, in <module>
19.03.19 23:11:12 (+0100) test-image import picamera.mmal as mmal
19.03.19 23:11:12 (+0100) test-image File "/usr/local/lib/python2.7/site-packages/picamera/mmal.py", line 47, in <module>
19.03.19 23:11:12 (+0100) test-image from .bcm_host import VCOS_UNSIGNED
19.03.19 23:11:12 (+0100) test-image File "/usr/local/lib/python2.7/site-packages/picamera/bcm_host.py", line 47, in <module>
19.03.19 23:11:12 (+0100) test-image _lib = ct.CDLL('libbcm_host.so')
19.03.19 23:11:12 (+0100) test-image File "/usr/local/lib/python2.7/ctypes/ __init__.py", line 366, in __init__
19.03.19 23:11:12 (+0100) test-image self._handle = _dlopen(self._name, mode)
19.03.19 23:11:12 (+0100) test-image OSError: libbcm_host.so: cannot open shared object file: No such file or directory

```

I have tried the example provided on [https://github.com/balena-io-projects/balena-rpi-python-picamera](https://github.com/balena-io-projects/balena-rpi-python-picamera) and I get the exact same result.

Can anyone look into this? I’m trying this on both a RPi Zero W and a RPi3-B

Thank you.

---

<div class="post-metadata">

**Author:** ![nelson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nelson/32/1303_2.png) [@nelson](https://forums.balena.io/u/nelson)\
**Post date:** [March 21, 2019, 9:45am UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672/4 "2019-03-21T09:45:03Z")

</div>

As a follow up on my previous post, the workaround to get this to work is to use the debian base image instead of the alpine and install `libraspberrypi-bin` package. Without it seems the shared libraries are not present.

Can someone double check that this example is actually working? [https://github.com/balena-io-projects/balena-rpi-python-picamera](https://github.com/balena-io-projects/balena-rpi-python-picamera)

thanks,  
nelson

---

<div class="post-metadata">

**Author:** ![thomask](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@thomask](https://forums.balena.io/u/thomask)\
**Post date:** [November 23, 2019, 2:59pm UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672/6 "2019-11-23T14:59:34Z")

</div>

Hey!  
I (still) got the same problem. The git example is also not working. Did all the configuration ([https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/](https://www.balena.io/docs/learn/develop/hardware/i2c-and-spi/)) and so on but still get the some error. Unfortunately your solution isn’t working either… ☹ Can’t install `libraspberrypi-bin` cause its not fount. Maybe this is cause I’m using an raspberry pi 4?

Have you found an other solution to this task?  
Thanks a lot!

Thomas

---

<div class="post-metadata">

**Author:** ![mbalamat](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mbalamat/32/1245_2.png) [@mbalamat](https://forums.balena.io/u/mbalamat)\
**Post date:** [November 25, 2019, 11:52am UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672/9 "2019-11-25T11:52:49Z")

</div>

Hi @thomask did you use this project [https://github.com/balena-io-projects/balena-rpi-python-picamera](https://github.com/balena-io-projects/balena-rpi-python-picamera) and tried to install the libraspberrypi-bin if not can you share your Dockerfile? Can you check if there are any /dev/video\* devices present (on host and on the container). Also a thing to try if you are using the balena-rpi-python-picamera project is to change this line [https://github.com/balena-io-projects/balena-rpi-python-picamera/blob/8eb2af20befd172943655b12355494dfdd1e1d90/Dockerfile.template#L1](https://github.com/balena-io-projects/balena-rpi-python-picamera/blob/8eb2af20befd172943655b12355494dfdd1e1d90/Dockerfile.template#L1) to use a raspberry pi 3 image.

---

<div class="post-metadata">

**Author:** ![nemis](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/nemis/32/4441_2.png) [@nemis](https://forums.balena.io/u/nemis)\
**Post date:** [September 6, 2020, 11:53am UTC](https://forums.balena.io/t/picamera-not-working-as-expected/5672/11 "2020-09-06T11:53:42Z")

</div>

Hi,  
I am having the same issues with an rpi4. also tried your last proposal and changed to using the following:  
`FROM balenalib/raspberrypi3-64-ubuntu-python`

Also tried with and without `modprobe v4l2_common` but that command does not work anyways…
