我有一台64位计算机,在/usr/local/bin/中安装了Python 3.5,在/usr/bin/中安装了Python 3.4. 解决方案 这是我启动Python 3.6并在Mac OS Sierra上使用GStreamer绑定等运行的方式. 遵循步骤1 ,如果您已经安装了Gstreamer及其插件,则需要将其绑定到python解释器进行开发. 0a-从其网站上正常安装gstreamer,然后 0b- brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav 1- brew install gst-python --with-python3但是请注意,由于某种原因'gtk'并未预先打包,因此我们转到步骤2. 2- brew install gtk + 3就是这样,就像 ABC ...随附了一个测试python代码,以确保您一切正常[可选] import gi, time, sysgi.require_version('Gst', '1.0')gi.require_version('GstBase', '1.0')gi.require_version('Gtk', '3.0')from gi.repository import GObject, Gst, GstBase, Gtk, GObjectclass Main: def __init__(self): Gst.init(None) self.pipeline = Gst.Pipeline() self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc', 'audio') self.pipeline.add(self.audiotestsrc) self.sink = Gst.ElementFactory.make('autoaudiosink', 'sink') self.pipeline.add(self.sink) self.audiotestsrc.link(self.sink) self.pipeline.set_state(Gst.State.PLAYING) time.sleep(3) self.pipeline.set_state(Gst.State.PAUSED) self.pipeline.set_state(Gst.State.READY) self.pipeline.set_state(Gst.State.NULL) sys.exit(0)start = Main()Gtk.main()希望一切正常,是的!I am using Debian Linux, and I have the package python3-gi installed from Synaptic, and this works fine if I use my Python 3.4 interpreter. But, when I run a Gtk+3 program using 3.5, it gets stuck at the from gi.repository import Gtk line, saying there's no module named Gtk. Additionally, I don't think that pip works for Python 3.5 on my computer, although I'm not sure. I just know that pip install PyGObject doesn't work. Finally, when I try to use Pycharm's specific package installer (Settings/Project Interpreter), Pycharm tells me that I don't have Python packaging tools installed (and it fails to install them when I click on the prompt it gives).I have a 64 bit computer, Python 3.5 is installed to /usr/local/bin/ and Python 3.4 is installed to /usr/bin/. 解决方案 This is how I got Python 3.6 up and running with GStreamer bindings etc. on my Mac OS Sierra.Follow from Step 1 if you have already installed Gstreamer and its plugins and you need to bind it to your python interpreter for development.0a- Install gstreamer from their website ...normally and then0b- brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav1- brew install gst-python --with-python3Note however that the 'gtk' for some reason doesn't come pre-bundled so we go to step 2.2- brew install gtk+3And that's it, easy as ABC...Attached is a test python code to make sure you got everything right [OPTIONAL]import gi, time, sysgi.require_version('Gst', '1.0')gi.require_version('GstBase', '1.0')gi.require_version('Gtk', '3.0')from gi.repository import GObject, Gst, GstBase, Gtk, GObjectclass Main: def __init__(self): Gst.init(None) self.pipeline = Gst.Pipeline() self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc', 'audio') self.pipeline.add(self.audiotestsrc) self.sink = Gst.ElementFactory.make('autoaudiosink', 'sink') self.pipeline.add(self.sink) self.audiotestsrc.link(self.sink) self.pipeline.set_state(Gst.State.PLAYING) time.sleep(3) self.pipeline.set_state(Gst.State.PAUSED) self.pipeline.set_state(Gst.State.READY) self.pipeline.set_state(Gst.State.NULL) sys.exit(0)start = Main()Gtk.main()Hope er'thing works out, c ya!! 这篇关于适用于Python 3.5.1的PyGObject?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!