python ete3在Gtk警告后创建pdf失败

2024-05-19 00:02:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我遇到了一个问题,找不到任何有用的信息。我在python中使用ete3来自动创建系统发育树图。我已经写了一些代码,如果我在我的ipython笔记本上执行的话,效果会很好。你知道吗

但是,当我通过python script.py在终端中运行它时,会收到以下警告消息:

GLib-GIO-Message: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.

(python:7657): Gtk-WARNING **: GModule (/usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ibus.so) initialization check failed: GLib version too old (micro mismatch)

(python:7657): Gtk-WARNING **: Loading IM context type 'ibus' failed

(python:7657): Gtk-WARNING **: GModule (/usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ibus.so) initialization check failed: GLib version too old (micro mismatch)

(python:7657): Gtk-WARNING **: Loading IM context type 'ibus' failed

(python:7657): Gtk-WARNING **: GModule (/usr/lib/x86_64-linux-gnu/gtk-2.0/2.10.0/immodules/im-ibus.so) initialization check failed: GLib version too old (micro mismatch)

(python:7657): Gtk-WARNING **: Loading IM context type 'ibus' failed

警告出现后,代码被卡住了,无法创建图形。我已经尝试更新glib库,但没有帮助。你知道吗

我使用的代码是:

def my_layout(node):
    F = TextFace(node.name, tight_text=True)
    add_face_to_node(F, node, column=0, position="branch-top")
    if node.is_leaf():
        seq_face = SeqMotifFace(node.sequence, seqtype='nt', seq_format='compactseq')
        add_face_to_node(seq_face, node, column=0, position='aligned')

def phylo_with_alignment(tree, alignment, out_dir, out_format):
    t2=PhyloTree(tree, alignment)
    t2.link_to_alignment(alignment=alignment, alg_format='fasta')
    ts2=TreeStyle()
    ts2.show_leaf_name=False
    ts2.layout_fn=my_layout
    print 'trying to render...'
    t2.render(out_dir.rstrip('/')+'/'+os.path.basename(tree)+'phylo_aln.'+out_format, tree_style=ts2)
    print 'Done!'

try:
    parse_fasta(args.alignment)
    phylo_with_alignment(tree, alignment, args.out_dir, args.out_format)
    print 'Tataaaa, phylogeny with alignment created and saved to %s!' % out_dir
except Exception, e:
    print 'EXCEPTION: %s, line %s' % (e, sys.exc_info()[-1].tb_lineno)
    sys.exit()

这里的目标是创建图形并将其保存到out_dir。错误发生在我调用t2.render()时,在此之前,一切都运行顺利。你知道吗

有人知道我能做些什么来解决这个问题吗?我已经看了How can I fix this error? Gtk-WARNING **: GModule ... initialization check failed: GLib version too old (micro mismatch)和相关的问题,但找不到答案。你知道吗


编辑:


调用conda remove glib会清除错误消息,但脚本仍然没有完成。 注意:在ipython笔记本中执行时,相同的代码也在工作


Tags: to代码nodetreeformatgtkdirwith

热门问题