I have similar issue trying to install livekit https://github.com/livekit/python-sdks 

(env) [opal_username@opal4 ~]$ pip install livekit
Collecting livekit
  Using cached livekit-0.12.1.tar.gz (67 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      Traceback (most recent call last):
        File "/home/opal_username/apps/app_name/env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/opal_username/apps/app_name/env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/opal_username/apps/app_name/env/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-yzwfq3vf/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-yzwfq3vf/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-yzwfq3vf/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 22, in <module>
      ImportError: cannot import name 'get_platform' from 'wheel.bdist_wheel' (/tmp/pip-build-env-yzwfq3vf/overlay/lib/python3.12/site-packages/wheel/bdist_wheel.py)
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I've downloaded the livekit python setup files into ~/opt/src but not sure what to do from here as it doesn't have the configure file.

I also tried to install without wheel but running into issue with

OSError: /lib64/libstdc++.so.6: version CXXABI_1.3.8' not found (required by /home/opal_username/opt/src/livekit-0.12.1/livekit/rtc/resources/liblivekit_ffi.so)

what would be easiest way to install this python module on Opalstack?

  • sean replied to this.

    009co I've tried various approaches and can't find a solution for the "cannot import name 'get_platform' from 'wheel.bdist_wheel'" error.

    What commands did you run that resulted in the "/lib64/libstdc++.so.6" error?

    009co Actually, I've just found a workaround by editing setup.py in the livekit Python sources. Here are the commands to install from source:

    # first activate your virtualenv, then:
    source scl_source enable devtoolset-11
    cd ~/opt/src
    git clone https://github.com/livekit/python-sdks.git
    cd python-sdks/livekit-rtc
    sed -iE 's/from wheel.bdist_wheel import get_platform/from wheel._bdist_wheel import get_platform/' setup.py
    pip install .

    Please give that a try 🙂

    Thank you! i was fiddling with variations of using setup.py : ) but yours does seem to install livekit.

    (env) [opalstack_username@opal4 src]$ source scl_source enable devtoolset-11
    (env) [opalstack_username@opal4 ~]$ cd opt/src
    (env) [opalstack_username@opal4 src]$ git clone https://github.com/livekit/python-sdks.git
    Cloning into 'python-sdks'...
    remote: Enumerating objects: 2134, done.
    remote: Counting objects: 100% (1226/1226), done.
    remote: Compressing objects: 100% (550/550), done.
    remote: Total 2134 (delta 891), reused 794 (delta 622), pack-reused 908
    Receiving objects: 100% (2134/2134), 1.63 MiB | 0 bytes/s, done.
    Resolving deltas: 100% (1226/1226), done.
    (env) [opalstack_username@opal4 src]$ cd python-sdks/livekit-rtc
    (env) [opalstack_username@opal4 livekit-rtc]$ sed -iE 's/from wheel.bdist_wheel import get_platform/from wheel._bdist_wheel import get_platform/' setup.py
    (env) [opalstack_username@opal4 livekit-rtc]$ pip install .
    Processing /home/opalstack_username/opt/src/python-sdks/livekit-rtc
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Preparing metadata (pyproject.toml) ... done
    Requirement already satisfied: protobuf>=3 in /home/opalstack_username/apps/appname/env/lib/python3.12/site-packages (from livekit==0.12.1) (5.27.3)
    Requirement already satisfied: types-protobuf>=3 in /home/opalstack_username/apps/appname/env/lib/python3.12/site-packages (from livekit==0.12.1) (4.25.0.20240417)
    Building wheels for collected packages: livekit
      Building wheel for livekit (pyproject.toml) ... done
      Created wheel for livekit: filename=livekit-0.12.1-py3-none-linux_x86_64.whl size=86478 sha256=3a2e2a7fefee9b0dc18860ea2e0f968b29fcfe01a7ddcdb237c325cb4b50260d
      Stored in directory: /home/opalstack_username/.cache/pip/wheels/f8/cb/f0/bb41e36997437ea12ee9208bde1f00b3ec05062d096b32e4aa
    Successfully built livekit
    Installing collected packages: livekit
    Successfully installed livekit-0.12.1

    It does seem to be installed. eg this works

    import livekit (good it works)

    but locally i can the following but it is not working in this remote env we just set up.

    from livekit import rtc (it doesn't work)
    from livekit.rtc import Room (it doesn't work)

    Not sure what to make of this. Any ideas?

    (env) [opalstack_username@opal4 python-sdks]$ python
    Python 3.12.4 (main, Jun  9 2024, 20:53:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import livekit
    >>> from livekit import rtc
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/__init__.py", line 30, in <module>
        from .audio_frame import AudioFrame
      File "/home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/audio_frame.py", line 16, in <module>
        from ._ffi_client import FfiHandle, FfiClient
      File "/home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/_ffi_client.py", line 60, in <module>
        ffi_lib = get_ffi_lib()
                  ^^^^^^^^^^^^^
      File "/home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/_ffi_client.py", line 57, in get_ffi_lib
        return ctypes.CDLL(str(path))
               ^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.12/ctypes/__init__.py", line 379, in __init__
        self._handle = _dlopen(self._name, mode)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^
    OSError: /home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/resources/liblivekit_ffi.so: cannot open shared object file: No such file or directory
    • nick replied to this.

      009co If this file does not exist in this path /home/opalstack_username/apps/appname/env/lib/python3.12/site-packages/livekit/rtc/resources/liblivekit_ffi.so (maybe it's in ~/opt/src?), then try locating it and including the path to it via LD_LIBRARY_PATH, e.g.:

      export LD_LIBRARY_PATH=/home/opalstack_username/path/to/library/:$LD_LIBRARY_PATH

      Actually the file "liblivekit_ffi.so" referenced in the error isn't anywhere to be found not even in github repo at the path "livekit/rtc/resources/liblivekit_ffi.so" the resources dir is empty.

      • nick replied to this.

        009co You can build the libraries using cargo. I redid the whole process as below but got stuck and haven't figured out a work around just yet, but maybe it will be helpful for you:

        source scl_source enable devtoolset-11 llvm-toolset-7
        #Need at least Python 3.9+
        python3.12 -m venv ~/myenv
        source ~/myenv/bin/activate
        mkdir -p ~/opt/src
        cd ~/opt/src
        git clone https://github.com/livekit/python-sdks.git
        cd python-sdks
        git submodule update --init --recursive
        cd livekit-rtc/rust-sdks/livekit-ffi
        export LIBCLANG_PATH=/opt/rh/llvm-toolset-7/root/usr/lib64
        cargo build --release
        cd ~/opt/src/python-sdks/livekit-rtc
        sed -iE 's/from wheel.bdist_wheel import get_platform/from wheel._bdist_wheel import get_platform/' setup.py
        pip install .
        export LD_LIBRARY_PATH=$HOME/opt/src/python-sdks/livekit-rtc/rust-sdks/target/release:$LD_LIBRARY_PATH
        
        #Create symlink to work around "No such file or directory"
        ln -sf $HOME/opt/src/python-sdks/livekit-rtc/rust-sdks/target/release/liblivekit_ffi.so $HOME/opt/src/python-sdks/livekit-rtc/livekit/rtc/resources/liblivekit_ffi.so
        
        #Test
        python -c "import livekit; from livekit import rtc"

        Thanks, that helped advance the attempt to install livekit module on Opalstack though with tons of warnings and ultimately not passing the test.

        What looks positive

        Successfully built livekit
        Installing collected packages: livekit
        Successfully installed livekit-0.12.1

        However the test

        python -c "import livekit; from livekit import rtc"

        resulted in an error

        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/home/opalstack_username/opt/src/python-sdks/livekit-rtc/livekit/rtc/__init__.py", line 30, in <module>
            from .audio_frame import AudioFrame
          File "/home/opalstack_username/opt/src/python-sdks/livekit-rtc/livekit/rtc/audio_frame.py", line 16, in <module>
            from ._ffi_client import FfiHandle, FfiClient
          File "/home/opalstack_username/opt/src/python-sdks/livekit-rtc/livekit/rtc/_ffi_client.py", line 60, in <module>
            ffi_lib = get_ffi_lib()
                      ^^^^^^^^^^^^^
          File "/home/opalstack_username/opt/src/python-sdks/livekit-rtc/livekit/rtc/_ffi_client.py", line 57, in get_ffi_lib
            return ctypes.CDLL(str(path))
                   ^^^^^^^^^^^^^^^^^^^^^^
          File "/usr/local/lib/python3.12/ctypes/__init__.py", line 379, in __init__
            self._handle = _dlopen(self._name, mode)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^
        OSError: /home/opalstack_username/opt/src/python-sdks/livekit-rtc/livekit/rtc/resources/liblivekit_ffi.so: undefined symbol: _ZN3rtc7LogSink12OnLogMessageERKSsNS_15LoggingSeverityEPKc

        ChatGPT and friends suggest the build is not matching environment?

        • sean replied to this.

          009co we've been trying to solve this for the past 24 hours but we're unable to get it working on our servers because the operating system is too old.

          We should have new servers with a new operating system available by the end of the 3rd quarter (in about 6-7 weeks). I've tested livekit on the new OS and confirm that it will work there. We'll make an announcement here in our forum when the new servers are ready.

            sean Hey Sean, great thanks for the quick, detailed, actionable responses, and the update!

            Mastodon