473,763 Members | 7,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can't run py app after compile to exe by py2exe , gettext

hi.

I use python 23,py2exe 0.4.3 ,wxpython do my py app in win32.
I use gettext to support multi languages. I build a small fuction for load
language at top of main module.
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~
def setLan(lan):
import gettext
langs = gettext.GNUTran slations(open (join ( localPath,
( "lan/"+lan+".mo" ) )
) )
langs.install()
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~

Above run normally in debug mode, when I compile to exe by py2exe.
the exe can't run, no error raised, I can see exe in task manager.
but after few seconds , exe disappear automaticlly.

If I remove the function setLan, EXE can show main GUI.
But the function I has used it in another app,python22 ,wxpython.

So I use other way of show multi language.
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~
def setLan():
t = gettext.transla tion("tbt", os.path.join(di r,"locale\\") ,
languages=['en'])
t.install()
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~

situation same as before, can run in script mode, exe can't show.
Remove this function, program ok.

I don't what happen , I have test many many times.
Somebody help me :(

ulysses
Jul 18 '05 #1
3 3645
I do a small test app for this. Still can't run.

~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~
#!/usr/bin/env python
#Boa:App:BoaApp

from wxPython.wx import *

def setLan():
import gettext
lan=gettext.GNU Translations(op en('en.mo'))
lan.install()

class BoaApp(wxApp):
def OnInit(self):
wxInitAllImageH andlers()
setLan()
self.main = wxFrame1(None)
# needed when running from Boa under Windows 9X
self.SetTopWind ow(self.main)
self.main.Show( );self.main.Hid e();self.main.S how()
return True

class wxFrame1(wxFram e):
def __init__(self, parent):
wxFrame.__init_ _(self, id=-1, name='', parent=parent,
pos=wxPoint(193 , 111), size=wxSize(505 , 223),
style=wxDEFAULT _FRAME_STYLE, title='wxFrame1 ')
self.SetClientS ize(wxSize(497, 196))
self.SetBackgro undColour(wxCol our(192, 192, 192))
self.SetFont(wx Font(14, wxSWISS, wxNORMAL, wxNORMAL, False, 'Tahoma'))

self.staticText 2 = wxStaticText(id =2222,
label=_('help me'), name='staticTex t2', parent=self, pos=wxPoint(72,
128), size=wxSize(336 , 40), style=0)

self.staticText 1 = wxStaticText(id =3333,
label=_('show text'), name='staticTex t1', parent=self,
pos=wxPoint(72, 56), size=wxSize(320 , 48), style=0)

def main():
application = BoaApp(0)
application.Mai nLoop()

if __name__ == '__main__':
main()

~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.

Ulysses
Jul 18 '05 #2
ul********@yaho o.com.cn (ulysses) writes:
I do a small test app for this. Still can't run. ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.


I tried it, and it seems you have to make sure that the en.mo file is in
the same directory as the exe, and you have to manually include the
'encodings' package - there's a command line switch for that.

To help to find these types of problems, it's always useful to build the
exe as a console version first with the --console command line flag to
py2exe. There's no way for the --windows exe to notify you of the
tracebacks.

And if you want to try the 0.5.0 version of py2exe (which requires
Python 2.3), here is the setup script you would use:

"""
from distutils.core import setup
import py2exe

setup(name='tes tgettext',
options = {"py2exe": {"packages": ["encodings"]}},
windows = ['main.py'],
data_files = [("", ["en.mo"])],
)
"""

The latest py2exe 0.5.0 creates windows programs in such a way that
tracebacks are routed into a log file (that would be 'main.exe.log' in
the above case), and even displayes a message box when the program ends
pointing the user to the logfile.

Thomas
Jul 18 '05 #3
Thomas Heller <th*****@python .net> wrote in message news:<ek******* ***@python.net> ...
Thank you very much.

I was killed this question. completely remove python22 and
python23,wxpyth on,py2exe. then reinstall python22,wxpyth on,py2exe
0.4.1.

Rewrite my source code to a new py file. it's work.
I still don't know where is bug. But I solve it.
maybe my code very confusion. Python don't like awful code. :)

anyway ,thanks Heller.

ul********@yaho o.com.cn (ulysses) writes:
I do a small test app for this. Still can't run.

~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~
full source package
please download from

http://211.90.187.42/ourbt/gettexttest.rar

you test in in your computer. Thanks.


I tried it, and it seems you have to make sure that the en.mo file is in
the same directory as the exe, and you have to manually include the
'encodings' package - there's a command line switch for that.

To help to find these types of problems, it's always useful to build the
exe as a console version first with the --console command line flag to
py2exe. There's no way for the --windows exe to notify you of the
tracebacks.

And if you want to try the 0.5.0 version of py2exe (which requires
Python 2.3), here is the setup script you would use:

"""
from distutils.core import setup
import py2exe

setup(name='tes tgettext',
options = {"py2exe": {"packages": ["encodings"]}},
windows = ['main.py'],
data_files = [("", ["en.mo"])],
)
"""

The latest py2exe 0.5.0 creates windows programs in such a way that
tracebacks are routed into a log file (that would be 'main.exe.log' in
the above case), and even displayes a message box when the program ends
pointing the user to the logfile.

Thomas

Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1920
by: Daniel CAUSSE | last post by:
Hello, I'm testing gettext on my website but it doesn't work. phpinfo returns correct informations: configure command => '--with-gettext=/usr' GetText Support => enabled I have no problem to create messages.mo and messages.po files. I've created all directories under a 'locale' root directory
1
1601
by: PythonMan | last post by:
warning: py2exe: * The following modules were not found: warning: py2exe: * SOCKS warning: py2exe: * rourl2path warning: py2exe: * ic when i compile btdownloadheadless.py of BitTorrent , justmsg is shown , the souce code should have no error , but why i get such error ? how get back this modules ? thx~~~ --
8
4738
by: Kathleen Kudzma | last post by:
Does anyone know how to resolve the following problem that I'm getting in Python 2.2 and 2.3? PROBLEM: When I try to create a classReader object I get an exception: "SAXReaderNotAvailable: No parsers found". This only happens when I run the ..EXE; it does not happen if I run the .PY file. When I'm running the .EXE this exception doesn't happen immediately. It happens as soon as I try to create a classReader object. Please see the...
14
2640
by: Pierre Rouleau | last post by:
I have a problem writing self-testable modules using doctest when these modules have internationalized strings using gettext _('...'). - The main module of an application (say app.py) calls gettext.install() to install the special _ function inside Python builtin. Other modules, taken from a general purpose collection of Python modules, also support internationalisation and doctest testing. For example:
3
5724
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the (Windows) ability, to add some version infos, comments, etc to the exe file. If I use explorer to check, these properties are visible and correct.
2
1284
by: billiejoex | last post by:
Hi all. I tried to compile this little source with py2exe: http://pastebin.com/350143 ....but once I execute the program I encount this error: C:\src\dist>sniffer.exe Traceback (most recent call last): File "sniffer.py", line 24, in ? File "sniffer.py", line 18, in get_int LookupError: no codec search functions registered: can't find encoding
10
2448
by: silverburgh.meryl | last post by:
I have a string array: colors = colorIndex = 0; and I want to loop thru each element of colors for str in strings: print colors
0
1239
by: mchristopher | last post by:
I'm having trouble compiling DOM XML support into PHP 4.4.2 on CentOS 4.3. Everytime I attempt to compile, it spits back this: .... chmod 755 /usr/lib/apache/libphp4.so Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/man/man1/ Installing PEAR environment: /usr/local/lib/php/ Archive_Tar - already installed: 1.3.1
0
1007
by: Alexandr N Zamaraev | last post by:
OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2) GNU ld (GNU Binutils) 2.18.50.20080109 OS: WinXP Home Ru + sp2 Python: 2.5.2 py2exe: latest CSV source gcc (GCC) 3.4.5 (mingw-vista special r2)
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.