livekit / python-sdks

LiveKit real-time and server SDKs for Python
https://docs.livekit.io
Apache License 2.0
127 stars 37 forks source link

Incompatible with protobuf 3.19.4 #117

Closed Liamazing closed 9 months ago

Liamazing commented 10 months ago

livekit v0.6.0 (with python3.9, ubuntu20.04) claims to be compatible with protobuf versions >=3.1.0, but import fails when installed alongside 3.19.4.

To reproduce, build the following Dockerfile and run python3.9 -c "from livekit import rtc" inside:

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python3.9-dev=3.9.5-3* python3-pip
RUN python3.9 -m pip install --upgrade pip
RUN python3.9 -m pip install ipython livekit==0.6.0 protobuf==3.19.4

output is:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/__init__.py", line 19, in <module>
    from ._proto.room_pb2 import (
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/_proto/room_pb2.py", line 8, in <module>
    from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (/usr/local/lib/python3.9/dist-packages/google/protobuf/internal/__init__.py)

Even after following the solution suggested here, import fails with the following output:

[2023-12-06T23:27:03Z INFO  livekit_ffi::server::requests] initializing ffi server v0.3.13
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/__init__.py", line 34, in <module>
    from .audio_stream import AudioStream
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/audio_stream.py", line 23, in <module>
    from .track import Track
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/track.py", line 26, in <module>
    class Track:
  File "/usr/local/lib/python3.9/dist-packages/livekit/rtc/track.py", line 40, in Track
    def kind(self) -> proto_track.TrackKind.ValueType:
  File "/usr/local/lib/python3.9/dist-packages/google/protobuf/internal/enum_type_wrapper.py", line 114, in __getattr__
    raise AttributeError('Enum {} has no value defined for name {!r}'.format(
AttributeError: Enum TrackKind has no value defined for name 'ValueType'
keepingitneil commented 9 months ago

We're going to bump the proto requirement to version 4: https://github.com/livekit/python-sdks/pull/124

Liamazing commented 9 months ago

@keepingitneil seems reasonable :+1: