Hi guys have a python software that i want to freeze for distribution. The problem is after freezing it with cx_freeze and i run it, it works fine on my development computer but when i sent it to my testing computer (window XP sp3 32bit) it give me this error

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'

the setup.py script for the building cx_freeze is

import sys

from cx_Freeze import setup, Executable

includes =['atexit']
packages = ['pyttsx','win32com.server','win32com.client']
base = None
if sys.platform == "win32":
    base = "Win32GUI"

        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)])

Note i don't have much expereince i

5 Years
Discussion Span
Last Post by Thomas Karl

I have done some tesing and got it to work(windows 7 Ultimate)
First my test code.

import pyttsx
import time
from datetime import date
from datetime import datetime

engine = pyttsx.init()

date = date.today()
time_now = datetime.now()
date = date.strftime("%A %d %B")
time_now = time_now.strftime('%H:%M:%S')

engine.say('The date is {} and time is now {}'.format(date, time_now))

Cx_freeze setup.

from cx_Freeze import setup,Executable

includes = ["pyttsx", "pyttsx.drivers.sapi5"]
excludes = []
packages = ['win32com.gen_py']

filename = "sound_test.py"
    name = 'myapp',
    version = '0.1',
    description = 'test pyttsx',
    author = 'no',
    author_email = 'someting@my.org',
    options = {'build_exe': {'excludes':excludes,'packages':packages,'includes':includes}},
    executables = [Executable(filename, base = "Win32GUI", icon = None)])

The hard part to figure out was pyttsx.drivers.sapi5 and win32com.gen_py
To run it sound_test.py and cx_run.py in same folder(freeze).
From command line(cmd)
C:\freeze>python cx_run.py build

Edited by snippsat


thanks bro this problem has been giving me a hard time. Why this problem
can you explain any futher so i can better under it.


by the way i am getting
ImportError: No module named 'win32com.gen_py'
when i run your cx_run.py script


ImportError: No module named 'win32com.gen_py'
when i run your cx_run.py script

Hard to say because it works for me.
Some info.
win32com.gen_py is part of Pywin32 package.
Placement on my hdd is C:\Python27\Lib\site-packages\win32com\gen_py
See if you have this placement.

Make sure that Environment Variables is set to python27.
To path add ;C:\python27\;C:\python27\scripts

Edited by snippsat


i have seen it but it is emty thus there is nothing in it. Can you post the content so i can download it.
i have even re installed pywin32 but still

Edited by otengkwaku


well it seems the problem is with the operating software it seems wind XP do not support pyttsx thanks very much i realy applicate your effort


Thanks for the info!!

includes = []
excludes = []
packages = ['win32com.gen_py']

options = {'build_exe': {'excludes':excludes,'packages':packages,'includes':includes}},

it worked fine for me!


What I would recommend instead is setting the path for the generated files to a writeable location.
For example by:

import win32com
win32com.__gen_path = os.path.join(os.path.split(file__)[0], "win32com_dir")

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.