raspberrypi / picamera2

New libcamera based python library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] ImportError: cannot import name 'V4L2_CID_MPEG_VIDEO_H264_PROFILE' from 'v4l2'

san4s204 opened this issue · comments

Please only report one bug per issue!

Describe the bug
Cannot use picamera2 with OpenCV

To Reproduce
If you have the same issue
$python3

Expected behaviour
No error when importing picamera2

Console Output, Screenshots
Traceback (most recent call last):
File "/home/dima/Desktop/test.py", line 2, in
from picamera2 import Picamera2
File "/usr/lib/python3/dist-packages/picamera2/init.py", line 9, in
from .picamera2 import Picamera2, Preview
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 26, in
from picamera2.encoders import Encoder, H264Encoder, MJPEGEncoder, Quality
File "/usr/lib/python3/dist-packages/picamera2/encoders/init.py", line 21, in
from .h264_encoder import H264Encoder
File "/usr/lib/python3/dist-packages/picamera2/encoders/h264_encoder.py", line 3, in
from v4l2 import (V4L2_CID_MPEG_VIDEO_H264_I_PERIOD,
ImportError: cannot import name 'V4L2_CID_MPEG_VIDEO_H264_PROFILE' from 'v4l2' (/home/dima/cv/lib/python3.11/site-packages/v4l2.py)

Hardware :
Please state what kind of Pi you are using, and what camera is attached.

Additional context
Add any other context about the problem here.
Raspberry Pi 4 Model B Rev 1.5
Raspberry Pi Camera rev 1.3

Name: v4l2-python3
Version: 0.3.2
Summary: Python bindings for the v4l2 userspace api.
Home-page: https://pypi.org/project/v4l2-python3/
Author:
Author-email:
License: GPLv2
Location: /home/dima/cv/lib/python3.11/site-packages

Name: picamera2
Version: 0.3.18
Summary: The libcamera-based Python interface to Raspberry Pi cameras, based on the original Picamera library
Home-page: https://github.com/RaspberryPi/picamera2
Author: Raspberry Pi & Raspberry Pi Foundation
Author-email: picamera2@raspberrypi.com
License: BSD 2-Clause License
Location: /usr/lib/python3/dist-packages

Hi, it sounds like you have an out of date version of python3-v4l2 - the latest is 0.3.4. Please update it and try again. Thanks!