Traits/UI (chaco) 绘图应用程序中断,当 运行 在 32 位 Anaconda 环境中,在 64 位 Ubuntu 16.04

Traits/UI (chaco) plotting application breaks, when run in a 32-bit Anaconda environment, on 64-bit Ubuntu 16.04

我有一个 Traits/UI (chaco) 绘图应用程序,它 运行 在我的 Anaconda 64 位安装的根环境中很好,在 64 位 Ubuntu 16.04 上。但是,当我尝试从我为测试创建的 32 位环境 运行 它时,它失败了。

出于某种原因,它似乎默认使用 "null" 图形后端工具包,给了我一个堆栈跟踪,因此结束:

File "/home/dbanas/anaconda2/envs/pybert_32/lib/python2.7/site-packages/enable/toolkit.py", line 40, in _init_toolkit format_exception_only(t, v)) ImportError: Unable to import the image backend for the null toolkit (reason: ['ImportError: libGL.so.1: cannot open shared object file: No such file or directory\n']).

所以,我意识到我的系统上没有安装 32 位 Gtk+ 库支持。我安装了那个。而且,现在,当我在我的 32 位环境中启动它时,应用程序段出现故障!这是来自 gdb 的堆栈跟踪:

> #0  0xf76e7f10 in ?? () from /lib/ld-linux.so.2
> #1  0xf76e8a4b in ?? () from /lib/ld-linux.so.2
> #2  0xf76ea7c9 in ?? () from /lib/ld-linux.so.2
> #3  0xf76f26bf in ?? () from /lib/ld-linux.so.2
> #4  0xf76ee204 in ?? () from /lib/ld-linux.so.2
> #5  0xf76f1f02 in ?? () from /lib/ld-linux.so.2
> #6  0xf74febf5 in ?? () from /lib/i386-linux-gnu/libdl.so.2
> #7  0xf76ee204 in ?? () from /lib/ld-linux.so.2
> #8  0xf74ff30d in ?? () from /lib/i386-linux-gnu/libdl.so.2
> #9  0xf74fec9e in dlopen () from /lib/i386-linux-gnu/libdl.so.2
> #10 0xf76523e6 in _PyImport_GetDynLoadFunc (fqname=0x8b72188 "PyQt4.QtCore", shortname=0x8b7218e "QtCore", 
>     pathname=0x8b73190 "/home/dbanas/anaconda2/envs/pybert_32/lib/python2.7/site-packages/PyQt4/QtCore.so",
> 
>     fp=0x8981b98) at Python/dynload_shlib.c:130
> #11 0xf7636512 in _PyImport_LoadDynamicModule (name=0x8b72188 "PyQt4.QtCore", 
>     pathname=0x8b73190 "/home/dbanas/anaconda2/envs/pybert_32/lib/python2.7/site-packages/PyQt4/QtCore.so",
> 
>     fp=0x8981b98) at ./Python/importdl.c:42
> #12 0xf76343c0 in load_module (name=0x8b72188 "PyQt4.QtCore", fp=<optimized out>, 
>     pathname=0x8b73190 "/home/dbanas/anaconda2/envs/pybert_32/lib/python2.7/site-packages/PyQt4/QtCore.so",
> type=3, 
>     loader=0x0) at Python/import.c:1937
> #13 0xf7634c43 in import_submodule (mod=0xf2b9c26c, subname=0x8b7218e "QtCore", fullname=0x8b72188 "PyQt4.QtCore")
>     at Python/import.c:2725
> #14 0xf7634ebc in load_next (mod=0xf2b9c26c, altmod=0xf2b9c26c, p_name=0xff97d7fc, buf=0x8b72188 "PyQt4.QtCore", 
>     p_buflen=0xff97d7f8) at Python/import.c:2539
> #15 0xf76354fb in import_module_level (level=-1, fromlist=0xf2b33c8c, locals=<optimized out>, globals=0xf2b2de84, 
>     name=0x0) at Python/import.c:2256
> #16 PyImport_ImportModuleLevel (name=0xf2b35264 "PyQt4.QtCore", globals=0xf2b2de84, locals=0xf2b2de84, 
>     fromlist=0xf2b33c8c, level=-1) at Python/import.c:2312
> #17 0xf7615e76 in builtin___import__ (self=0x0, args=0xf2b352fc, kwds=0x0) at Python/bltinmodule.c:49
> #18 0xf75b6188 in PyCFunction_Call (func=0xf72cf78c, arg=0xf2b352fc, kw=0x0) at Objects/methodobject.c:85
> #19 0xf756bb9c in PyObject_Call (func=0xf72cf78c, arg=0xf2b352fc, kw=0x0) at Objects/abstract.c:2547
> #20 0xf7616454 in PyEval_CallObjectWithKeywords (func=0xf72cf78c, arg=0xf2b352fc, kw=0x0) at Python/ceval.c:4221
> #21 0xf761a8aa in PyEval_EvalFrameEx (f=0xf4ba19cc, throwflag=0) at Python/ceval.c:2624
> #22 0xf761ff25 in PyEval_EvalCodeEx (co=0xf2b361d0, globals=0xf2b2de84, locals=0xf2b2de84, args=0x0, argcount=0, 
>     kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3584
> ---Type <return> to continue, or q <return> to quit---

所以,我刚刚取得了一些进步:

在我的 Python 应用程序中更改以下代码:

from traits.trait_base import ETSConfig
# ETSConfig.toolkit = 'qt4'
ETSConfig.toolkit = 'wx'

导致一些有用的错误消息被打印到我的控制台,关于丢失的库。经过数次序列迭代后:

dpkg -S libGLU.so.1
sudo apt-get install libglu1-mesa:i386

我的申请成功了!然而,GUI 的颜色都搞砸了,当我第一次启动它时,我收到一个警告对话框,其中包含以下消息:

iCCP: known incorrect sRGB profile 07:07:37

所以,现在,我有两个问题:

  1. 如何修复 "wx" 版本的颜色?
  2. 如何让 "qt4" 版本吐出关于缺少库的相同类型的有用消息,而不仅仅是 seg。出错了?

啊哈!安装那些缺少的 32 位库已修复段。错误,我的 "qt4" 版本也是 运行ning。而且,GUI 颜色是正确的! :)

问题是缺少 32 位库,这并不奇怪,因为我是 运行 64 位 Ubuntu。但是,让系统告诉我缺少哪些库需要将 Python GUI 应用程序从 qt4 back-end 更改为 wx back-end,像这样:

from traits.trait_base import ETSConfig
# ETSConfig.toolkit = 'qt4'
ETSConfig.toolkit = 'wx'

通过尝试获取 "wx" 模式 运行 提示我执行的 32 位库安装足以获取 "qt4" 模式 运行,还有。而且,这很重要,因为 "wx" 模式会产生愚蠢的 GUI 颜色,而 "qt4" 模式会产生正确的 GUI 颜色。