使用cx_freeze制作exe时出现EnsureDispatch错误 [英] EnsureDispatch error when using cx_freeze for making exe

查看:77
本文介绍了使用cx_freeze制作exe时出现EnsureDispatch错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows 7上使用Python 3.4。

I am working with Python 3.4 on Windows 7. My setup file is as follows:

from cx_Freeze import setup, Executable, sys

exe=Executable(
 script="XYZ.py",
 base="Win32Gui",

 )
includefiles=[]
includes=[]
excludes=[]
packages=[]
setup(

 version = "1.0",
 description = "XYZ",
 author = "MAX",
 name = "AT",
 options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
 executables = [exe]
 )


from distutils.core import setup
import py2exe, sys, os, difflib

sys.argv.append('py2exe')
setup(
    options = {'py2exe': {'bundle_files': 1}},
    console = [{'script': "XYZ.py"}],
    zipfile = None,
    )

运行获得的exe时,弹出错误提示:

When the obtained exe is run, an error pops up saying:

...
File "C:\Python34\Lib\site-packages\win32com\client\CLSIDToClass.py", line 46, in GetClass
    return mapCLSIDToClass[clsid]
KeyError: '{00020970-0000-0000-C000-000000000046}'

我只是无法在这里找出问题所在。

I just can't figure out the problem here. Help, please.

谢谢。

推荐答案

您正在使用静态代理在磁盘上生成,并且具有编译后的可执行文件查找故障。如果您不知道静态代理是什么,则可能使用的是 win32com.client.gencache.EnsureDispatch ,它会自动生成静态代理。

You are using static proxy which is generated on your disk and which has the compiled executable trouble finding. If you do not know what the static proxy is, you are probably using win32com.client.gencache.EnsureDispatch which generates static proxy automatically.

解决此问题的最简单方法是使用 win32com.client.dynamic.Dispatch 使用动态代理。静态代理有一些好处,但是很有可能不需要它。

The easiest way to fix the problem is to use dynamic proxy by using win32com.client.dynamic.Dispatch. Static proxy has some benefits, but there is a high possibility that you do not need it.

您可以在此处找到有关COM对象的静态和动态代理的更多信息:< a href = http://timgolden.me.uk/python/win32_how_do_i/generate-a-static-com-proxy.html rel = nofollow> http://timgolden.me.uk/python/win32_how_do_i/ generate-a-static-com-proxy.html

You can find more information about static and dynamic proxies to COM objects here: http://timgolden.me.uk/python/win32_how_do_i/generate-a-static-com-proxy.html

这篇关于使用cx_freeze制作exe时出现EnsureDispatch错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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