picamera: picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': I/O error

I’m using Raspberry Pi 3 Model B+.

vcgencmd get_camera gives me supported=1 detected=1

raspistill -o test.jpg gives me the test.jpg file but also gives this message

mmal: mmal_vc_shm_init: could not initialize vc shared memory service
mmal: mmal_vc_component_create: failed to initialise shm for 'vc.camera_info' (7:EIO)
mmal: mmal_component_create_core: could not create component 'vc.camera_info' (7)
mmal: Failed to create camera_info component

Then, I try to run this python code below, but it gives me this error message

from picamera import PiCamera
camera = PiCamera()

Error:

mmal: mmal_vc_shm_init: could not initialize vc shared memory service
mmal: mmal_vc_component_create: failed to initialise shm for 'vc.camera_info' (7:EIO)
mmal: mmal_component_create_core: could not create component 'vc.camera_info' (7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/picamera/camera.py", line 367, in __init__
    with mo.MMALCameraInfo() as camera_info:
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 2346, in __init__
    super(MMALCameraInfo, self).__init__()
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 633, in __init__
    prefix="Failed to create MMAL component %s" % self.component_type)
  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to create MMAL component b'vc.camera_info': I/O error

About this issue

Commits related to this issue

Most upvoted comments

@6by9

For anyone who has written camera-based applications in the past, this is a very significant change, and is too large to be covered here. There will be a blog post dedicated to the new camera driver published soon, so watch this space!

I really don’t believe that this is the right way for the RPi Foundation to communicate such a big change, and I understand why many are frustrated with it.

There are thousands of scripts and examples out there that reference picamera, and they have been written over many years. There are even Android apps built around the way picamera streams video feeds. I have built many pieces of automation that leverage picamera to stream and record video between devices, and they’ve all been broken by the bullseye upgrade.

You can’t get away with a random blog post that says “hey guys, FYI we’ve decided to completely kill the old picamera API, we’ll let you know as soon as we have time how you are supposed to migrate your scripts”. You can’t even expect people to go through blog posts before a dist-upgrade to validate whether anything is going to break upon reboot. This is the best way to get developers pissed, and it has another unfortunate precedent (the way the omxplayer layer has been left to break and rot on its own without viable alternatives). What I would have expected:

  • The picamera relevant pages (Github, documentation and pypi) should have reported, in big capital letters and with reasonable notice before bullseye was released as a new stable, WARNING: This library is deprecated and is going to break in bullseye, [link to migration steps here]. If people are opening issues on this topic, it probably means that a breaking change wasn’t properly communicated.
  • A warning upon pip/apt install/upgrade (or import) of picamera on bullseye that clearly warns the user about the deprecation.
  • A back-compatibility layer: the v4l2 API is widely used and documented, but the picamera module provides an API that makes it easier to e.g. start a video stream or record with a preview even for a beginner, without having to mangle with ffmpeg/gstreamer/v4l2/gtk internals. The picamera module could have simply relied on e.g. a gstreamer wrapper instead of the proprietary interface, while providing the same external interface to maintain back-compatibility with previously written software. I’m pretty sure that lots of beginners out there would have loved a back-compatible way of writing a script to stream a camera feed in three lines of code.
  • A viable alternative: I’ve given the Pi camera a try with my ffmpeg and gstreamer Python streamers, and the performance is not at all comparable. This reminds me, again, about the messy deprecation of omxplayer: “omxplayer is falling apart, don’t use it anymore, use vlc instead, but we are also aware that vlc is not there yet when it comes to RPi integration”. When you deprecate something, make sure that you communicate it properly, and that you provide a satisfying alternative to the thing that you are deprecating.

We’re all happy to see the RPi software finally transition towards a more open-source approach, leaving behind legacy and hard-to-debug software like picamera or omxplayer. But we also expect the alternatives to be properly documented and supported. Many people out there rely on RPi software for stuff like media or camera playback: you can’t just break their software without providing and documenting the alternatives.

You can still enable the legacy stack, but the default is now libcamera. https://forums.raspberrypi.com/viewtopic.php?t=323390

Python bindings for libcamera are already in the works.

UPDATE AS OF 02/08/22* As mentioned by @danielfaust Just a note on @lexodistro 's solution.

According to https://downloads.raspberrypi.org/raspios_armhf/release_notes.txt the 2022-01-28 release re-added support for the old camera stack (“Legacy camera applications and libraries reinstalled”) and raspi-config got a new option to enable the legacy stack raspi-config - add option to switch to legacy camera mode.

This means that it is enough to issue a sudo apt update; sudo apt dist-upgrade and after the reboot issue sudo raspi-config to enable the legacy camera stack in the 3 Interface Options-section.

If you were holding the old packages you’d need to unhold them before doing the dist-upgrade:

sudo apt-mark unhold libraspberrypi0 sudo apt-mark unhold libraspberrypi-bin sudo apt-mark unhold libraspberrypi-dev sudo apt-mark unhold libraspberrypi-doc

sudo apt update; sudo apt upgrade and then after the reboot issue the sudo apt dist-upgrade


Original Post with spelling corrections (thanks @worldofchris)

Bro

In order to get the piCamera modules not to throw errors I had to manually update my repositories for bullseye this is important to do or else you will get errors like so

mmal: mmal_component_create_core: could not find component ‘vc.camera_info’ Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/usr/lib/python3/dist-packages/picamera/camera.py”, line 367, in init with mo.MMALCameraInfo() as camera_info: File “/usr/lib/python3/dist-packages/picamera/mmalobj.py”, line 2346, in init super(MMALCameraInfo, self).init() File “/usr/lib/python3/dist-packages/picamera/mmalobj.py”, line 631, in init mmal_check( File “/usr/lib/python3/dist-packages/picamera/exc.py”, line 184, in mmal_check raise PiCameraMMALError(status, prefix)

To fix this run these commands to update the repositories and remove the vlc errors

sudo apt-get remove --purge vlc-nox
sudo apt-get autoclean
sudo dpkg --configure -a
sudo apt-get -f install
sudo apt-get autoremove
sudo apt-get update
sudo apt-get dist-upgrade

Then make sure to reenable the legacy camera interface

sudo raspi-config

Then enable it

After this do a reboot

sudo reboot

Then send me lots of thanks its quick and dirty but you can run PiCamera on bullseye and then update to Libcamera when they release picamer2 with the python3 bindings!!! be well and hope this helped someone. And I know I know you don’t need to use the -get anymore just a habit that’s hard to shake.

Raspberry Pi is becoming low-rent Apple.

This is what worked for me:

wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi0_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-bin_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-dev_1.20210831-1_armhf.deb
wget http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/libraspberrypi-doc_1.20210831-1_armhf.deb

sudo apt purge vcdbg
sudo dpkg -i raspberrypi-bootloader_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi0_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-bin_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-dev_1.20210831-1_armhf.deb
sudo dpkg -i libraspberrypi-doc_1.20210831-1_armhf.deb

sudo apt-mark hold raspberrypi-bootloader
sudo apt-mark hold libraspberrypi0
sudo apt-mark hold libraspberrypi-bin
sudo apt-mark hold libraspberrypi-dev
sudo apt-mark hold libraspberrypi-doc

vcdbg needs to be removed because it is included in libraspberrypi-bin, else libraspberrypi-bin would not install.

But I still have a question: doing an apt search raspberrypi yields:

raspberrypi-bootloader/stable 1:1.20211029-1 armhf [upgradable from: 1:1.20210831-1] -- Raspberry Pi bootloader
libraspberrypi0/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV
libraspberrypi-bin/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- Miscellaneous Raspberry Pi utilities
libraspberrypi-dev/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV (headers)
libraspberrypi-doc/stable 1:2+git20210928~141951+6e8f786-2 armhf [upgradable from: 1:1.20210831-1] -- EGL/GLES/OpenVG/etc. libraries for the Raspberry Pi's VideoCore IV (headers)

firmware-brcm80211/stable,now 1:20210315-3+rpt3 all [installed] -- Binary firmware for Broadcom/Cypress 802.11 wireless cards
libraspberrypi-bin-dbgsym/stable 1:2+git20210928~141951+6e8f786-2 armhf -- debug symbols for libraspberrypi-bin
libraspberrypi0-dbgsym/stable 1:2+git20210928~141951+6e8f786-2 armhf -- debug symbols for libraspberrypi0
raspberrypi-kernel/stable,now 1:1.20211029-1 armhf [installed] -- Raspberry Pi bootloader
raspberrypi-kernel-headers/stable 1:1.20211029-1 armhf -- Header files for the Raspberry Pi Linux kernel
raspberrypi-net-mods/stable,now 1.3.2 all [installed] -- Network configuration for the Raspberry Pi UI
raspberrypi-sys-mods/stable,now 20211005+bullseye armhf [installed] -- System tweaks for the Raspberry Pi
raspberrypi-ui-mods/stable 1.20211110 armhf -- Config to customise the LXDE UI for the Raspberry Pi

So I’m wondering how safe it is to leave the latter not-upgradeable entries at the newest version, specially libraspberrypi-bin-dbgsym and libraspberrypi0-dbgsym

In any case, thank you for your help, because now it works.

Another question: libraspberrypi-bin contains /usr/bin/raspistill and /usr/bin/raspivid, at least according to https://packages.ubuntu.com/focal-updates/arm64/libraspberrypi-bin/filelist

So, could it be that it is not necessary to compile and install userland as described above ( where git clone https://github.com/raspberrypi/userland is mentioned )?

Well, it worked fine for me.

And, yes, un-holding and upgrading is sufficient to undo this.

Go to http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/

Download

libraspberrypi0_1.20210831-1_armhf.deb libraspberrypi-bin_1.20210831-1_armhf.deb libraspberrypi-dev_1.20210831-1_armhf.deb libraspberrypi-doc_1.20210831-1_armhf.deb raspberrypi-bootloader_1.20210831-1_armhf.deb

as root, do "dpkg -i " for all those files. You may need to remove vcdbg or make other package adjustments so that those fit.

Afterwards, do “apt-mark hold” for all of them so that future apt upgrades don’t overwrite them until that bug gets fixed.

That’s not enough. If you attempt this with the current libraspberrypi0/bootloader packages, what you get is “Failed to create MMAL component b’vc.camera_info’: Function Not Implemented.” You have to backtrack those packages to the 20210831-1 versions for now.