我想使用cx_Freeze編譯Python 3.3腳本。 該腳本使用win32com.client來控制MediaMonkey。當我直接運行它時,這是完美的。但是當我編譯它時,它會拋出這個異常。python:win32com和cx_Freeze - 錯誤
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 = '[email protected]',
options = {'build_exe': {
'excludes':excludes,
'packages':packages,
'includes':includes
}},
executables = [Executable(filename, base = None, icon = None)])
它是從你的簡短示例腳本中得到的錯誤嗎? –
[此消息](https://sourceforge.net/mailarchive/message.php?msg_id=25457945)建議您在凍結時需要包含'win32com.gen_py'包。讓我知道這是否有幫助。 –
是的,這是一樣的錯誤。 – ninov