1

大家好,我有一个 python 软件,我想冻结它以进行分发。问题是在用 cx_freeze 冻结它并运行它之后,它在我的开发计算机(win 7)上运行良好,但是当我将它发送到我的测试计算机(window 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'
4

2 回答 2

1

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

于 2013-05-20T19:19:12.343 回答
0

我建议你使用 pyttsx3。只要您更改语音引擎以适合您正在使用的计算机,例如 Windows 10 的 sapi 5,它就可以更快、更容易地编程并适用于所有设备。

于 2020-05-20T03:14:15.847 回答