Compilation error for python script in exe using py2exe and pyttsx

I have a python script that I created and it uses pyttsx to output text to speech. Whenever I converted it to exe using py2exe and tried to run exe, I get the following error:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
  File "pyttsx\__init__.pyc", line 39, in init
  File "pyttsx\engine.pyc", line 45, in __init__
  File "pyttsx\driver.pyc", line 66, in __init__
  File "pyttsx\drivers\sapi5.pyc", line 37, in buildDriver
  File "pyttsx\drivers\sapi5.pyc", line 46, in __init__
  File "win32com\client\__init__.pyc", line 317, in WithEv
AttributeError: 'NoneType' object has no attribute 'CLSID'

Here is a copy of my setup.py:

from distutils.core import setup
import py2exe

setup(
    console=['main.py'],
    options = {
        "py2exe":{
            "includes":[
                'pyttsx.drivers.sapi5'
            ]
        }
    }
)
+4
source share
1 answer

YEY - I got a job!

from distutils.core import setup
import py2exe

py2exe_options = { 'includes': ['pyttsx.drivers.sapi5', 'win32com.gen_py.C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4'],
                   'typelibs': [('{C866CA3A-32F7-11D2-9602-00C04F8EE628}', 0, 5, 4)] }

setup(console=['main.py'], options = {'py2exe': py2exe_options})

Please note that this requires that you run the same version (v5.4 in my case) on both machines. If you want to get around this, you probably need to try something more advanced .

+3
source

Source: https://habr.com/ru/post/1543792/


All Articles