Gtk 问题:ModuleNotFoundError:没有名为“gtk"的模块 [英] Gtk problem :ModuleNotFoundError: No module named 'gtk'

查看:217
本文介绍了Gtk 问题:ModuleNotFoundError:没有名为“gtk"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 gnuhealth,当我运行 gnuhealthclient 并使用我的用户名和密码登录时,它显示了一个带有 gtk 问题的错误消息:找不到模块

我正在使用 centos 7,并且我已经使用以下命令安装了 gtk+ 和 gtk3:

$sudo yum install gtk3

$sudo yum install gtk3-devel

$sudo yum install gtk+

当我检查已安装的软件包列表时,我发现了 gtk+ 和 gtk3 甚至 gtk 2

谁能告诉我这是什么问题?

这是错误消息:

<预><代码>如果不是 self.screen.row_activate() 和 self.children_field:文件/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/main.py",第 707 行,在 menu_row_activate},警告=假)文件/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/action/main.py",第 195 行,在 exec_keywordAction._exec_action(动作,数据,上下文=上下文)文件/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/action/main.py",第 155 行,在 _exec_actioncontext_domain=action['context_domain'])文件/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/window/window.py",第31行,在创建从 .form 导入表单文件/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/window/form.py",第9行,在<module>进口gtkModuleNotFoundError: 没有名为gtk"的模块```

解决方案

你的 .py 文件应该附上

<块引用>

导入 gtk

应该换成

<块引用>

从 gi.repository 导入 Gtk

在 Gnuhealth 源代码中,一些文件包含两个库调用,其他文件只调用 gtk 库而不精确源存储库.代码不是很干净.

感谢这里的这些解释:gi.repository 是 PyGObject(代表 Python GObject 自省)的 Python 模块,它包含 Python 绑定和对 GTK+ 3 工具包和 GNOME 应用程序的支持

I have installed gnuhealth and when I run the gnuhealthclient and login with my username and password it shows an error message with gtk problem : no module found

I am using centos 7 and I already installed gtk+ and gtk3 with these commands:

$sudo yum install gtk3

$sudo yum install gtk3-devel

$sudo yum install gtk+

When I check the list of installed packages I found gtk+ and gtk3 and even gtk 2

Can anyone tell me what is the problem?

Here’s the error msg:


    if not self.screen.row_activate() and self.children_field:

  File "/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/main.py", line 707, in menu_row_activate

    }, warning=False)

  File "/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/action/main.py", line 195, in exec_keyword

    Action._exec_action(action, data, context=context)

  File "/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/action/main.py", line 155, in _exec_action

    context_domain=action['context_domain'])

  File "/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/window/window.py", line 31, in create

    from .form import Form

  File "/home/gnuhealth/.local/lib/python3.6/site-packages/tryton/gui/window/form.py", line 9, in <module>

    import gtk
ModuleNotFoundError: No module named 'gtk'```

解决方案

Your .py files should enclose

import gtk

that should be replaced by

from gi.repository import Gtk

In Gnuhealth source code, some files enclose both of libraries calls, others just call the gtk library without precising the source repository. The code is not very clean.

Thanks to these explanations here : gi.repository is the Python module for PyGObject (which stands for Python GObject introspection) which holds Python bindings and support for the GTK+ 3 toolkit and for the GNOME apps

这篇关于Gtk 问题:ModuleNotFoundError:没有名为“gtk"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆