内省究竟是什么意思?它对程序员有什么用?有人可以用通俗的语言解释一下吗?
此前我劝如何升级到Rhythmbox音乐播放器到2.99.1版本有人在这里。但是,由于未安装 gobject-introspection-1.0,他们无法升级。我帮不了他们。
现在,有了一台全新的电脑,我遇到了和他们一样的问题。这是结果 ov./configure
simon@simon-TS44HR:~/Downloads/rhythmbox-2.99.1$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for gobject-introspection... configure: error: gobject-introspection-1.0 is …
Run Code Online (Sandbox Code Playgroud) 升级到 Ubuntu 14.04 后,gnome 中的对话框 system-config-printer 在从命令行调用时遇到问题:
sudo system-config-printer
Traceback (most recent call last):
File "/usr/share/system-config-printer/system-config-printer.py", line 72, in <module>
from gi.repository import GObject # for TYPE_STRING and TYPE_PYOBJECT
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 32, in <module>
raise ImportError('When using gi.repository you must not import static '
ImportError: When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".
Run Code Online (Sandbox Code Playgroud)
当我尝试更改包中的建议导入时,问题仍然存在,即,
cd /usr/share/system-config-printer
sed -i 's/import gobject/from gi.repository import GObject/g' *.py …
Run Code Online (Sandbox Code Playgroud) 这些库/术语在 GNOME 开发中有什么区别或关系?
从 Ubuntu 20.04 更新到 Ubuntu 20.10 后,我无法在 Python 虚拟环境上运行 PyGObject 应用程序。
我可以按照以下简单步骤重现该问题:
sudo apt-get install python3-venv
python3 -m venv venv
source env/bin/activate
pip install PyGObject==3.38.0
python3 hw.py
Run Code Online (Sandbox Code Playgroud)
hw.py
标准的 PyGObject Hello World 在哪里:
#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
window = Gtk.Window(title="Hello World")
window.show()
window.connect("destroy", Gtk.main_quit)
Gtk.main()
Run Code Online (Sandbox Code Playgroud)
当我尝试运行它时,它会抛出以下错误:
$ python3 hw.py
Traceback (most recent call last):
File "hw.py", line 3, in <module>
import gi
File "/home/leinardi/temp/hw/venv/lib/python3.8/site-packages/gi/__init__.py", line 40, in <module>
from . import _gi
ImportError: libffi.so.7: …
Run Code Online (Sandbox Code Playgroud)