如何在 macOS 上安装 gst-python 以使用推荐的 GStreamer 安装程序?

问题描述 投票:0回答:1

我正在尝试让以下内容在 M1 Pro 上的 macOS 14.4.1 上运行:

$ python3
Python 3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import gi
>>> gi.require_version('GLib', '2.0')
>>> gi.require_version('GObject', '2.0')
>>> gi.require_version('Gst', '1.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/homebrew/lib/python3.12/site-packages/gi/__init__.py", line 126, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gst not available

注:

$ which python3
/opt/homebrew/bin/python3

我发现了这个问题:Installing gst-python in macOS。看来我需要安装 gst-python 。我已经安装了 GStreamer 的 1.24 运行时和开发安装程序 - 在阅读那里的注释后我选择不使用 Homebrew - 但显然 gst-python 没有随它一起安装。

StackOverflow 问题 @chronosynclastic 描述了克隆 gstreamer GitLab 存储库,然后构建 gst-python 子项目,所以我尝试了同样的操作:

$ meson setup builddir -Dpygi-overrides-dir=/opt/homebrew/lib/python3.12/site-packages/gi/overrides && ninja -C builddir
The Meson build system
Version: 1.4.0
Source dir: /Users/dspitzer/dev/from_gitlab/gstreamer/subprojects/gst-python
Build dir: /Users/dspitzer/dev/from_gitlab/gstreamer/subprojects/gst-python/builddir
Build type: native build
Project name: gst-python
Project version: 1.24.1.1
C compiler for the host machine: cc (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
C linker for the host machine: cc ld64 1053.12
Host machine cpu family: aarch64
Host machine cpu: aarch64
Found pkg-config: YES (/Library/Frameworks/GStreamer.framework/Versions/1.0/bin/pkg-config) 0.29.2
Run-time dependency gstreamer-1.0 found: YES 1.24.1
Run-time dependency gstreamer-base-1.0 found: YES 1.24.1
Run-time dependency gmodule-no-export-2.0 found: YES 2.74.4
Library dl found: YES
Found CMake: /opt/homebrew/bin/cmake (3.29.1)
Run-time dependency pygobject-3.0 found: NO (tried pkgconfig, framework and cmake)
Looking for a fallback subproject for the dependency pygobject-3.0

meson.build:26:16: ERROR: Neither a subproject directory nor a pygobject.wrap file was found.

A full log can be found at /Users/dspitzer/dev/from_gitlab/gstreamer/subprojects/gst-python/builddir/meson-logs/meson-log.txt

但我不知道如何修复“发现运行时依赖 pygobject-3.0:否”。

注意: l'L'l 的评论指出上面的

pip3
命令使用的是不同版本的 Python。我修复了这个问题——所以你可以跳到下面的“更新”。

我找到了这个 StackOverflow 答案(和评论)并成功运行了

brew install pygobject3 gtk+3
但是:

$ pip3 install pygobject
Collecting pygobject
  Using cached pygobject-3.48.1.tar.gz (714 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      + meson setup /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129 /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129/.mesonpy-aial33lr -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dtests=false -Dwheel=true --wrap-mode=nofallback --native-file=/private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129/.mesonpy-aial33lr/meson-python-native-file.ini
      The Meson build system
      Version: 1.4.0
      Source dir: /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129
      Build dir: /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129/.mesonpy-aial33lr
      Build type: native build
      Project name: pygobject
      Project version: 3.48.1
      C compiler for the host machine: cc (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
      C linker for the host machine: cc ld64 1053.12
      Host machine cpu family: aarch64
      Host machine cpu: aarch64
      Program python3 found: YES (/Users/dspitzer/.new_local/share/pyenv/versions/3.11.7/bin/python3.11)
      Found pkg-config: YES (/Library/Frameworks/GStreamer.framework/Commands/pkg-config) 0.29.2
      Run-time dependency python found: YES 3.11
      Found CMake: /opt/homebrew/bin/cmake (3.29.1)
      Run-time dependency gobject-introspection-1.0 found: NO (tried pkgconfig, framework and cmake)
      Not looking for a fallback subproject for the dependency gobject-introspection-1.0 because:
      Use of fallback dependencies is disabled.

      ../meson.build:29:9: ERROR: Dependency 'gobject-introspection-1.0' is required but not found.

      A full log can be found at /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-thqb1k2v/pygobject_ad81b1b46af0427a953b312d45c6e129/.mesonpy-aial33lr/meson-logs/meson-log.txt
      [end of output]

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

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

更新:我已将

$HOME/.new_local/bin
(由 GStreamer 安装创建)添加到我的 PATH 中,位于
/opt/homebrew/bin
之前,因此
pip3
正在运行前者中的那个,这导致了不同版本的 Python。

所以我修复了路径并重新运行:

$ pip3 install pygobject
Collecting pygobject
  Downloading pygobject-3.48.2.tar.gz (715 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 715.2/715.2 kB 13.3 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      + meson setup /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d/.mesonpy-rhycpxqs -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dtests=false -Dwheel=true --wrap-mode=nofallback --native-file=/private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d/.mesonpy-rhycpxqs/meson-python-native-file.ini
      The Meson build system
      Version: 1.4.0
      Source dir: /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d
      Build dir: /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d/.mesonpy-rhycpxqs
      Build type: native build
      Project name: pygobject
      Project version: 3.48.2
      C compiler for the host machine: cc (clang 15.0.0 "Apple clang version 15.0.0 (clang-1500.3.9.4)")
      C linker for the host machine: cc ld64 1053.12
      Host machine cpu family: aarch64
      Host machine cpu: aarch64
      Program python3 found: YES (/Users/dspitzer/dev/python/dashboard-fake-frontend/env/bin/python3.12)
      Found pkg-config: YES (/Library/Frameworks/GStreamer.framework/Versions/1.0/bin/pkg-config) 0.29.2
      Run-time dependency python found: YES 3.12
      Found CMake: /opt/homebrew/bin/cmake (3.29.1)
      Run-time dependency gobject-introspection-1.0 found: NO (tried pkgconfig, framework and cmake)
      Not looking for a fallback subproject for the dependency gobject-introspection-1.0 because:
      Use of fallback dependencies is disabled.

      ../meson.build:29:9: ERROR: Dependency 'gobject-introspection-1.0' is required but not found.

      A full log can be found at /private/var/folders/sb/329vdstd77q73c_7j_smp9r40000gp/T/pip-install-i7tjs1ue/pygobject_d272551047184d069c19b9453f89f97d/.mesonpy-rhycpxqs/meson-logs/meson-log.txt
      [end of output]

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

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

所以 Python 版本不是问题。

现在我被困在这里了。

python macos gstreamer pygobject
1个回答
0
投票

我找到了另一个问题的答案:https://stackoverflow.com/a/72600498/4766

我安装了Miniconda然后运行:

conda create --name conda_env python=3.12.2
conda init zsh
conda activate conda_env
conda install -c conda-forge pygobject
conda install gtk3
conda install gstreamer

现在可以了:

python3
Python 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:54:21) [Clang 16.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import gi
>>> gi.require_version('GLib', '2.0')
>>> gi.require_version('GObject', '2.0')
>>> gi.require_version('Gst', '1.0')
>>>
© www.soinside.com 2019 - 2024. All rights reserved.