I have a Raspberry pi 4B with Ubuntu, and I’m trying to use my camera module 3 with python (I’ve tested the code with Raspberry Pi OS, so I know it’s right) using PiCamera and in a virtual environment (because otherwise I wouldn’t be able to install external packages). However, when I run the code, it says:

Traceback (most recent call last):
  File "/home/flamethrower/Desktop/CameraCode/headshots_picam.py", line 2, in <module>
    from picamera import PiCamera
  File "/home/flamethrower/cameravenv/lib/python3.11/site-packages/picamera/__init__.py", line 72, in <module>
    from picamera.exc import (
  File "/home/flamethrower/cameravenv/lib/python3.11/site-packages/picamera/exc.py", line 41, in <module>
    import picamera.mmal as mmal
  File "/home/flamethrower/cameravenv/lib/python3.11/site-packages/picamera/mmal.py", line 49, in <module>
    _lib = ct.CDLL('libmmal.so')
  File "/usr/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libmmal.so: cannot open shared object file: No such file or directory

(program exited with code: 1)

I've tried a test code, but it says the same thing. What should I do?

1 Answer 1


libmal.so is not supported on a 64bit OS, as per https://github.com/raspberrypi/firmware/issues/1558#issuecomment-983483179

Try using libcamera instead.

Source: https://stackoverflow.com/questions/71787870/oserror-libmmal-so-cannot-open-shared-object-file-no-such-file-or-directory-w

Your Answer

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

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