'Missing libmmal.so with picamera library

After installing the picamera library using pip, whenever I import the library I get this error:

OSError: libmmal.so: cannot open shared object file: No such file or directory

I am running ubuntu 14.04, with python 2.7.6.

When I attemt to search for this elusive libmmal.so:

$ sudo find / -name libmmal.so
/root/mounts/backups/root/opt/vc/lib/libmmal.so
/root/mounts/root-backup/opt/vc/lib/libmmal.so

Both of which are backups of my raspberry pi, and are therefore irrelevant.



Solution 1:[1]

On a raspberry, the libmmal.so library should be located at /opt/vc/lib, did you by any chance wipe this folder?

The firmware located in that directory is updated via

sudo rpi-update

If this tells you that you are already at the newest version, you can force an update by prior running

sudo rm /boot/.firmware_version

Please also see my other answer.

Are you running ubuntu 14.04 on your rpi? If not, i think you will have to recompile the libraries from the firmware.

Solution 2:[2]

I had the same problem using Raspbian based on Debian Bullseye, so if you install the Raspbian Lagacy and activate the camera everything should work properly. But if you want to use Rasbian based on Debian Bullseye then proceed the following steps:

  • Make sure that the camera is properly connected to the camera port with flat cable and Legacy camera is activated under raspi-config -> interfaces

  • Update:

    sudo apt update
    
  • Check if the path for libmmal.so exists under /opt/vc/lib or /lib/arm-linux-gnueabihf/:

    sudo ldconfig -p | grep mmal
    
  • If not, update Raspberry Pi firmware and reboot:

    sudo rpi-update
    sudo reboot
    
  • Check if there exists video0 under /dev: ls /dev/, then it should works.

  • If not, it is recommended to increase the GPU memory (under Performance Options -> GPU Memory) to >=128MB and then add the following to the /boot/config.txt:

    start_x=1
    
  • Read/enable the raspberry pi camera module:

    modprobe bcm2835-v4l2
    
  • To load the module automatically add bcm2835-v4l2 to /etc/modules.

  • Reboot and then video0 should be appeared under /dev.

  • Test the camera:

    from picamera import PiCamera
    from time import sleep
    
    camera = PiCamera()
    
    camera.start_preview()
    sleep(5)
    camera.stop_preview()
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2