import gtk/glib 产生 ImportError: DLL load failed

发布于 2024-09-06 05:19:00 字数 1173 浏览 3 评论 0原文

我在 Windows XP SP3 上从各自的网站安装了最新版本的 python (2.6.5)、gtk+、pygtk(和朋友)。当您尝试导入 gtk(或只是 glib)时,会引发 ImportError:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 38, in <module>
    import gobject as _gobject
  File "C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "C:\Python26\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
    from glib._glib import *
ImportError: DLL load failed: The specified procedure could not be found.

大约 6 个月前,它在同一台机器上运行,尽管这次我已经重新安装了。我尝试了不同版本的库,但仍然无法使其工作。

一些页面 与此相关,但没有提出解决方案,我无法找一个。

I installed the latest versions of python (2.6.5), gtk+, pygtk (and friends) from their respective websites on Windows XP SP3. When you try to import gtk (or just glib for that matter), an ImportError is raised:

Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 38, in <module>
    import gobject as _gobject
  File "C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "C:\Python26\lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <module>
    from glib._glib import *
ImportError: DLL load failed: The specified procedure could not be found.

This was working on the same machine around 6 months ago, although this time around I have re-installed. I tried different versions of the libraries but still couldn't get it to work.

There are a couple of pages out there relating to this, but not suggest a solution, and I'm unable to find one.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

弥繁 2024-09-13 05:19:00

我通过安装 Windows GTK+ 运行时解决了这个问题,如本链接所示
http://www.gramps-project.org/wiki/index .php?title=Windows_installer#Installation

另请参阅专门用于解决 Windows 上导入错误的页面:http://www.gramps-project.org/wiki/index.php?title=ImportError:_DLL_load_failed

I got a work around this by installing the windows GTK+ runtime as indicated in this link
http://www.gramps-project.org/wiki/index.php?title=Windows_installer#Installation

Also see their page dedicated to troubleshooting import errors on windows: http://www.gramps-project.org/wiki/index.php?title=ImportError:_DLL_load_failed

离去的眼神 2024-09-13 05:19:00

我自己设法解决了这个问题。首先,可能有多个原因,因此这可能无法帮助所有人。

我检查了 PATH 系统环境变量,并删除了所有指向旧版本 gtk+ 的路径(例如,与应用程序一起打包的路径)。

I managed to solve this myself. Firstly, there can be more than one cause so this may not help everyone.

I went through the PATH system environment variable and removed all paths that pointed to old versions of gtk+ (for example, those that come packaged with applications).

雪若未夕 2024-09-13 05:19:00

同样的问题,答案是从 grampy 页面重新安装 pygtk。
这是pygtk的问题,而不是系统或gtk的问题。
(在此之前, import pygtk 效果很好)

Same problem, answer was to reinstall pygtk from grampy page.
It was problem of pygtk, not system or gtk.
(Before this, import pygtk works well)

因为看清所以看轻 2024-09-13 05:19:00

我在 Windows 7 64 上遇到了同样的问题。我尝试安装多个版本的 python 2.6,并且 一体化 pygtk 也应该为您提供 GTK+。这个安装程序似乎没有做任何事情。然后我安装了最新版本的 GTK+(来自 binary)、pygtk、pycairo 和 gobject (所有说明均在 pygtk 下载 网站上进行了解释)。当我这样做时,我得到了上面给出的 ImportError: DLL load failed: 找不到指定的过程。

解决方案是卸载 pygtk、pycairo、gobject 并从我的路径变量中删除 GTK+ bin 位置。然后我去了这里并执行了前 5 个步骤(按此顺序)在“依赖关系 - 困难的方式”下。现在它起作用了。注意:我没有安装 gramps,只是安装了 pygtk 部分(前 5 个步骤)。

I had this same exact problem on Windows 7 64. I tried installing multiple versions of python 2.6, and the all-in-one pygtk that is supposed to give you GTK+ also. This installer didn't seem to do anything. Then I installed the latest versions of GTK+ (from binary), pygtk, pycairo, and gobject (all explained on the pygtk downloads website). When I did this, I got the ImportError: DLL load failed: The specified procedure could not be found. that is given above.

The SOLUTION was to uninstall pygtk, pycairo, gobject and remove the GTK+ bin location from my path variable. Then I went here and did the first 5 steps (in that order) under "Dependencies - The Hard Way". And now it works. Note: I didn't install gramps, just the pygtk part (first 5 steps).

離人涙 2024-09-13 05:19:00

一些报告表明技巧是首先导入 pygtk。你尝试过吗?

Some reports indicate that the trick is to import pygtk first. Have you tried that?

仙气飘飘 2024-09-13 05:19:00

我已将 gtk 模块(站点包:gtk-2.0、pygtk.py、cairo)复制到其他 python 安装中并遇到了相同的问题。

发生这种情况是因为我忘记复制 site-packages/pygtk.pth。

I have copied gtk module (site-packages: gtk-2.0, pygtk.py, cairo) to other python installation and encountered the same problem.

It was happening because I forgot to copy site-packages/pygtk.pth.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文