I have written a python application with using pyttsx library . its working without any issue from tt.py file. I compiled this tt.py file using py2exe module. after compilation i tried to run .exe file. then its shows error like given image
my setup.py file like this
from distutils.core import setup
import py2exe, sys, os
#includes =['drivers','drivers.sapi5'] #this tried. but making error
sys.argv.append('py2exe')
setup(
options = {'py2exe': {}},
console=['tt.py'],
)
i compiled by this command
python setup.py py2exe install
i am importing following modules in tt.py
import pyttsx
import pyttsx.drivers.sapi5
import win32com
from time import sleep
How can i fix this?
Looking at your imports you need to add import time
If your problem consist use cx freeze it is like py to exe and use a code like this.
It might also be a good idea to upgrade to python 3.3. This may sort some problems.
This might help it is a article on your error. https://mail.python.org/pipermail/python-win32/2006-January/004184.html
import pyttsx
import pyttsx.drivers.sapi5
import win32com
from time import sleep
import sys
from cx_Freeze import setup, Executable
setup(
name = "tt.py",
version = "0.1",
description = "your discription",
executables = [Executable("The file name", base = "Win32GUI")])
here's the link to cx freeze http://cx-freeze.sourceforge.net/
Here's the tutorial on how to use it http://cx-freeze.readthedocs.org/en/latest/overview.html
I tried cx_Freeze for a couple of minutes, but when it didn't work out immediately I tried some more with py2exe and got this working:
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=['tt.py'], options = {'py2exe': py2exe_options})
Note though that this requires you to run the same version (v5.4 in my case) on both machines. If you want to circumvent that you probably need to try something more advanced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With