在windows中使用py2xe的pyttsx編譯錯誤。

[英]pyttsx compilation error in windows using py2xe


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 enter image description here

我已經編寫了一個使用pyttsx庫的python應用程序。它的工作沒有任何問題。py文件。我編譯這個tt。py文件使用py2exe模塊。編譯后,我嘗試運行.exe文件。然后它的顯示錯誤就像給定的圖像。

my setup.py file like this

我的設置。py文件這樣的

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

我將在tt.py中導入以下模塊。

import pyttsx
import pyttsx.drivers.sapi5
import win32com
from time import sleep

How can i fix this?

我怎么解決這個問題?

2 个解决方案

#1


3  

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.

如果您的問題是使用cx凍結,那么exe就像py一樣,並使用這樣的代碼。

It might also be a good idea to upgrade to python 3.3. This may sort some problems.

升級到python 3.3可能也是一個好主意。這可能會解決一些問題。

This might help it is a article on your error. https://mail.python.org/pipermail/python-win32/2006-January/004184.html

這可能有助於它是一篇關於你的錯誤的文章。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/

這里是cx凍結的鏈接http://cx-freeze.sourceforge.net/。

Here's the tutorial on how to use it http://cx-freeze.readthedocs.org/en/latest/overview.html

下面是關於如何使用http://cx-freeze.readthedocs.org/en/latest/overview.html的教程。

#2


1  

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:

我嘗試了幾分鍾cx_Freeze,但是當它沒有成功的時候,我嘗試了更多的py2exe,並得到了這個工作:

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.

注意,這需要在兩台機器上運行相同的版本(我的例子中是v5.4)。如果你想規避,你可能需要嘗試更高級的東西。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/02/09/7299440745a441fc457a2f46b6a5c7de.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com