我想运行现有的简单示例并使用 GStreamer 编写一些简单的代码 - 具体来说,使用其 Python 绑定。我想安装软件包等来启用它。
这是一个例子。
http://brettviren.github.io/pygst-tutorial-org/pygst-tutorial.html
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
# ...
my_playbin = Gst.ElementFactory.make("playbin", None)
assert my_playbin
print my_playbin
我无法让 PyGObject 工作,所以我被困在import gi
并且无法取得超出第一线的任何进展。
该平台是MacOS 10.12.6和Python 3.6.5。
computer:Desktop me$ python3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gi'
>>>
好吧,让我们RTFM。
https://pygobject.readthedocs.io/en/latest/getting_started.html#macosx-getting-started
看起来很简单,这应该安装 PyGObject,对吧?
我已经安装了 Homebrew,但为了确保安全,我们再安装一次。
computer:Desktop me$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
[Snip for brevity]
==> Installation successful!
==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
computer:Desktop me$
好的,现在让我们安装 pygobject3 和 gtk+3
computer:Desktop me$ brew install pygobject3 gtk+3
Updating Homebrew...
Warning: pygobject3 3.32.1 is already installed and up-to-date
To reinstall 3.32.1, run `brew reinstall pygobject3`
Warning: gtk+3 3.24.8 is already installed and up-to-date
To reinstall 3.24.8, run `brew reinstall gtk+3`
computer:Desktop me$
现在让我们再次尝试Python:
computer:Desktop me$ python3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gi'
>>>
因此,我们按照说明进行操作,但仍然处于开始状态,没有任何功能。
也尝试了各种--with-python3
and --without-python
在brew安装过程中的选项。
computer:Desktop me$ brew install pygobject3 --with-python3 --without-python
Updating Homebrew...
[SNIP FOR BREVITY]
Error: invalid option: --with-python3
尽管在各种互联网线程中都提到了所有这些选项,但它们都是无效选项。
computer:Desktop me$ brew install pygobject3 --with-python@2 gtk+3
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.
[SNIP FOR BREVITY]
Error: invalid option: --with-python@2
有人可以告诉我我错过了什么吗?