与cx_freeze和pyttsx的win32com错误

时间:2013-05-19 14:02:16

标签: python pywin32 cx-freeze

大家好我有一个python软件,我想冻结分发。问题是用cx_freeze冻结后我运行它,它在我的开发计算机上工作正常(赢7)但是当我把它发送到我的测试计算机(窗口XP sp3 32bit)时它给我这个错误

Traceback(mostresent call last):
File "C:Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line27, in <module?
File "timeTracker.py", line 555, in <module>
File "timeTracker.py", line 381, in __init__
File "timeTracker.py", line 427, in runTimeThread
File "timeTracker.py", line 494, in __init__
File "timeTracker.py", line 118, in __init__
File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\__init__.py", line 39, in init
File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\engine.py", line 45, in __init__
File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\driver.py", line 66, in __init__
File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\drivers\sapi5.py", line 37, in buildDriver
File "C:Python27\lib\site-packages\pyttsx1.1-py2.7.egg\pyttsx\drivers\sapi5.py", line 46, in __init__
File "C:Python27\lib\site-packages\win32com\client\__init__.py", line 317, in WithEvents
AttributeError: 'NoneType' object has no attribute 'CLSID'

这是我的setup.py

import sys
from cx_Freeze import setup, Executable
includes =['atexit']
packages = ['pyttsx','win32com.server','win32com.client']
base = None
if sys.platform == "win32":
    base = "Win32GUI"
setup(
        name = "timeTracker",
        version = "1.0.0",
        description = "Keep track of your time take control of your life",
        options = {"build_exe" : {"includes" : includes, "packages": packages }},
        executables = [Executable("timeTracker.py", base = base)])
在setup.py中的

我尝试将'win32com.gen_py'添加到包列表但是出错了

No module call 'win32com.gen_py'

2 个答案:

答案 0 :(得分:1)

似乎pyttsx在Windows XP方面存在问题。经过仔细测试搜索后我得出结论,窗口XP没有对语音引擎进行任何测试,这就是pyttsx失败的原因

答案 1 :(得分:0)

我建议您使用pyttsx3。只要您更改语音引擎以使其适合所使用的计算机(例如适用于Windows 10的sapi 5),它的方式就会更快,更容易编程,并且可以与所有设备一起使用。