我安装了 ubuntu 12.04 64 位,并安装了 python 2.7 和一些附加软件包。当我尝试在 python 中使用简单命令时,例如,help('modules')
出现错误并且 python 终止。
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
from gtk import _gtk
** (python:2729): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
from gtk import _gtk
Segmentation fault (core dumped)
此外,我无法安装 matplotlib。在一个很长的错误日志中,除了其他内容之外,我还有:
pkg-config: looking for pygtk-2.0 gtk+-2.0
* Package pygtk-2.0 was not found in the pkg-config
* search path. Perhaps you should add the directory
* containing `pygtk-2.0.pc' to the PKG_CONFIG_PATH
* environment variable No package 'pygtk-2.0' found
* Package gtk+-2.0 was not found in the pkg-config
* search path. Perhaps you should add the directory
* containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH
* environment variable No package 'gtk+-2.0' found
* You may need to install 'dev' package(s) to
* provide header files.
Gtk+: no
* Could not find Gtk+ headers in any of
* '/usr/local/include', '/usr/include',
* '/usr/local/include', '/usr/include', '.'
我尝试从 synaptic 安装 gtk,但找不到与 gtk 完全匹配的库,因此安装了我认为最接近的依赖库。我不确定如何测试是否正确安装了它以及如何修复我的 python 问题
答案1
要构建和安装 matplotlib,您需要安装必要的依赖项。在这种情况下,您似乎缺少python-gtk2-dev
。
至于help('modules')
python 中的崩溃,很可能是因为它试图同时加载内省绑定以及旧的静态绑定;这将导致崩溃,因为它们支持的不兼容库中存在冲突的符号。