From: Luanne C. <lua...@gm...> - 2005-01-03 06:06:18
|
Hi, I too am trying to use py2exe for a simple PythonCard application. I followed the guidelines in this thread, but am stuck with a couple of issues. The first is, when I use py2exe, I get the following message at the end of a huge stream of output: The following modules appear to be missing ['Image', 'win32evtlog', 'win32evtlogutil'] However, the dist directory does get created and I can see the exe. When I try to run the exe, this is the output I get: Traceback (most recent call last): File "AutoPhoto.py", line 181, in ? File "PythonCard\model.pyc", line 337, in __init__ File "PythonCard\resource.pyc", line 48, in getResource File "PythonCard\resource.pyc", line 86, in __init__ File "PythonCard\resource.pyc", line 91, in __init__ File "PythonCard\resource.pyc", line 91, in __init__ File "PythonCard\resource.pyc", line 96, in __init__ File "PythonCard\resource.pyc", line 139, in enforceSpec File "PythonCard\resource.pyc", line 30, in loadComponentModule ImportError: cannot import module 'button What am I doing wrong? Thanks very much, Luanne On Fri, 3 Dec 2004 11:33:02 -0500, jon...@wa... <jon...@wa...> wrote: > > > I found a script that will out-put the PythonCard components of a resourc= e > file. > I did not write it, so I can't take credit for it. I only updated it for > the 0.8 release. > > Usage: resource.py yourresourcefile.rsrc.py > > #!/usr/bin/python2.3 > > import sys > #from PythonCardPrototype import res > from PythonCard import resource > > def GetResourceImports(rsrcFileName): > rsrcImports =3D [] > builtinimport =3D __builtins__.__dict__['__import__'] > def wrapimport(name, globals, locals, fromlist): > rsrcImports.append((name, fromlist)) > return apply(builtinimport, (name, globals, locals, fromlist)) > __builtins__.__dict__['__import__'] =3D wrapimport > rsrcFile =3D resource.ResourceFile(rsrcFileName) > rsrc =3D rsrcFile.getResource() > # revert to old import > __builtins__.__dict__['__import__'] =3D builtinimport > return rsrcImports > > def importcommand(name, fromlist): > # """returns a string containing a command to import the module referre= d > to by name, fromlist""" > # either it's a tuple: import stuff from a module > if type(fromlist) =3D=3D tuple: > return "from "+name+" import "+",".join(fromlist) > # or it's a import from a package > elif type(fromlist) =3D=3D list: > namelist =3D name.split('.') > prefixlen =3D len(fromlist) > for n in range(prefixlen): > if fromlist[n] !=3D namelist[n]: > prefixlen =3D n > break > if prefixlen =3D=3D 0: > return "import "+name > else: > # if prefixlen>1, we have a problem... > return "from "+".".join(namelist[:prefixlen])+" import > "+".".join(namelist[prefixlen:]) > # or it's just a simple import > else: > return "import "+name > > def tryimports(imports): > print "import traceback" # for handling errors > for name, fromlist in imports: > # print name, fromlist > print "try:" > print " ",importcommand(name, fromlist) > print "except ImportError:" > print " traceback.print_exc()" > > if __name__ =3D=3D '__main__': > rsrcFileName =3D sys.argv[1] > imports =3D GetResourceImports(rsrcFileName) > if '--allcomponents' in sys.argv: > tryimports(imports) > else: > # by default, handle PythonCard component imports > print "#!/usr/bin/python2.2" > print ''' > """This file was autogenerated by resimports.py to import all the > PythonCard components referred to by %s > > This is useful in generating dependencies for an installer > """ > ''' % rsrcFileName > for name, fromlist in imports: > if fromlist =3D=3D ['components']: > print importcommand("PythonCardPrototype."+name, > ['PythonCardPrototype']+fromlist) > > Jonathan Papageorgiou > > |---------+--------------------------------------------> > | | Gregory Pi=F1ero | > | | <gre...@gm...> | > | | Sent by: | > | | pyt...@li...ur| > | | ceforge.net | > | | | > | | | > | | 12/01/2004 04:11 PM | > | | Please respond to Gregory Pi=F1ero | > | | | > |---------+--------------------------------------------> > >-----------------------------------------------------------------------= -------------------------------------------------------| > | = | > | To: Ruben Marquez <rmc...@ya...> = | > | cc: pyt...@li... = | > | Subject: Re: [Pythoncard-users] Using py2exe with pythoncard = | > >-----------------------------------------------------------------------= -------------------------------------------------------| > > > Wow it finally worked! Thanks! > > I just had to add: > from PythonCard.components import > button,image,staticbox,statictext,textarea,textfield > > Though I'm slightly dissapointed it didn't make just one big exe file, > but rather a whole folder of junk. Do I need to bring that whole > folder to another computer in order to run my program? > > Wish me luck on my presentation tonight on a computer that I'm not > allowed to install python on ;-) > > -Greg > > On Wed, 1 Dec 2004 12:35:18 -0800 (PST), Ruben Marquez > <rmc...@ya...> wrote: > > Gregory, > > > > I know, there is a lot to take in when you are getting > > started. Note that Kevin said: > > > > "You need to specifically import the component modules > > that you use in your resource file" > > > > What that means is that, when using py2exe, you have > > to explicitly import each component that you use in > > your app individually. In other words, it is not > > enough to do: > > > > from PythonCard import model, dialog, etc... > > > > In addition to that, you need to do: > > > > from PythonCard.components import button, radiogroup, > > etc... > > > > -Ruben > > > > > > __________________________________ > > Do you Yahoo!? > > Read only the mail you want - Yahoo! Mail SpamGuard. > > http://promotions.yahoo.com/new_mail > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- http://ladyluanne.blogspot.com --=20 http://ladyluanne.blogspot.com |