我正在尝试使用 cx_Freeze 编译 Python 3.3 脚本。该脚本使用 win32com.client 来控制MediaMonkey。当我直接运行它时,这很完美。但是当我编译它时,它会抛出这个异常。
Traceback (most recent call last):
File "O:\Python\3\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module>
exec(code, m.__dict__)
File "test.py", line 6, in <module>
sdb = win32com.client.DispatchWithEvents("SongsDB.SDBApplication", MMEventHandler)
File "O:\Python\3\lib\site-packages\win32com\client\__init__.py", line 260, in
DispatchWithEvents
clsid = disp_class.CLSID
AttributeError: 'NoneType' object has no attribute 'CLSID'
当我尝试编译一个非常短的脚本时,它甚至不起作用win32com.client
:
import win32com.client
class MMEventHandler:
pass
sdb = win32com.client.DispatchWithEvents("SongsDB.SDBApplication", MMEventHandler)
这是我的 setup.py 脚本:
from cx_Freeze import setup, Executable
includes = []
excludes = []
packages = ['win32com', 'shlex', 'os', 'pythoncom', 'base64', 'tornado']
filename = "test.py"
setup(
name = 'Test',
version = '0.1',
description = 'test',
author = 'no',
author_email = 'someting@my.org',
options = {'build_exe': {
'excludes':excludes,
'packages':packages,
'includes':includes
}},
executables = [Executable(filename, base = None, icon = None)])