Skip to content

Python Bindings on Bullseye #304

@fiepfiep

Description

@fiepfiep

Steps to reproduce:

start from raspberry pi os Bullseye (lite) 64 bit.

python3 
import libcamera

works fine now

then, remove libcamera from apt, because we want to build our own:

sudo apt remove libcamera0

install libcamera according to:
rpi documentation

python3
>>> import libcamera
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'libcamera'

errors out.

why does this happen...:

...
installing symlink pointing to libcamera-base.so.0.5.2 to /usr/local/lib/aarch64-linux-gnu/libcamera-base.so.0.5
Installing symlink pointing to libcamera-base.so.0.5 to /usr/local/lib/aarch64-linux-gnu/libcamera-base.so
Installing symlink pointing to libpisp.so.1.2.1 to /usr/local/lib/aarch64-linux-gnu/libpisp.so.1
Installing symlink pointing to libpisp.so.1 to /usr/local/lib/aarch64-linux-gnu/libpisp.so
Installing symlink pointing to libcamera.so.0.5.2 to /usr/local/lib/aarch64-linux-gnu/libcamera.so.0.5
Installing symlink pointing to libcamera.so.0.5 to /usr/local/lib/aarch64-linux-gnu/libcamera.so
Running custom install script '/home/pi/libcamera/src/ipa/ipa-sign-install.sh /home/pi/libcamera/build/src/ipa-priv-key.pem lib/aarch64-linux-gnu/libcamera/ipa/ipa_rpi_vc4.so lib/aarch64-linux-gnu/libcamera/ipa/ipa_rpi_pisp.so'

libcamera shared objects are in : /usr/local/lib/aarch64-linux-gnu but this is not in python path.
libcamera package is in: /usr/local/lib/python3/dist-packages/libcamera/

where does python look for packages?

>>> import sys
>>> sys.path
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.9/dist-packages']

the libcamera location is not there.

how to solve this? Add another folder to the python path:
export PYTHONPATH=/usr/local/lib/python3/dist-packages:$PYTHONPATH

now libcamera import works.

why is the current behavior like this? why not install to a folder that is part of the python sys path?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions