编辑: 我已经尝试导入 /usr/lib/girepository-1.0
中代表的几乎所有库,通过 gi.repository
它们都可以正常工作,除了 Gtk 和 Gdk。我已更新标题以反映这一点。
我需要一个自建的 PyGObject 库来配合自建的 Python 3.3.3 使用。我使用 sudo apt-get build-dep python3-gi
安装了 PyGObject 的所有依赖项。我发现工作系统的 PyGObject 版本是 3.2.2,所以我从 Git 存储库中检出了版本 3.2.2 的源代码。然后我运行了以下命令:
autoreconf --force --install ./configure --prefix=/home/tomas/.pyenv/versions/3.3.3 make make install
一切都编译和安装得很好。我打开了一个新的 CMD 窗口,并将工作目录设置为 ~
,然后执行了以下操作:
~$ python Python 3.3.3 (default, Dec 21 2013, 23:12:28) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from gi.repository import Gtk Segmentation fault (core dumped) ~$
我将 LD_LIBRARY_PATH
设置为 /home/tomas/.pyenv/versions/3.3.3/lib
并检查了正确的库是否被加载:
~$ ldd .pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/_gi.so linux-vdso.so.1 => (0x00007fffcdf51000) libgirepository-1.0.so.1 => /usr/lib/libgirepository-1.0.so.1 (0x00007f45d8304000) libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f45d80b5000) libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f45d7dbf000) libpyglib-gi-2.0-python.so.0 => /home/tomas/.pyenv/versions/3.3.3/lib/libpyglib-gi-2.0-python.so.0 (0x00007f45d7bba000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f45d799d000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f45d75dc000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f45d72e0000) libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f45d70dc000) libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f45d6d8c000) libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f45d6b84000) libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f45d6947000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f45d673e000) /lib64/ld-linux-x86-64.so.2 (0x00007f45d877b000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f45d653a000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f45d6323000) libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f45d6103000) libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f45d5ee7000)这是一个关于it技术的内容,展示了一个python模块所需要的依赖库。
我也使用
python -vv
导入了模块:Pastebin。
最后几行显示,导入gi.repository.Atk
之后就会出现核心转储:
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.cpython-33m.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.abi3.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.py # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.pyc # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.cpython-33m.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.abi3.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.so # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.py # trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.pyc import 'gi.repository.Atk' # Segmentation fault (core dumped)
仅导入gi.repository.Atk
不会出现分段错误。
我还尝试删除系统版本的库(sudo dpkg -P python3-gi
),以防它在某种程度上干扰。
我不知道还能做什么。有人知道或有什么想法是什么问题吗?如果您有任何想法可以尝试或者需要提供更多信息请留言。