From: <gre...@gm...> - 2004-11-28 22:37:07
|
Hi everyone, I'm trying to use py2exe on a small pythoncard app I made but when I try to run the exe it says errors occured and in the log file it says: Traceback (most recent call last): File "JobRater.py", line 60, in ? File "PythonCard\model.pyc", line 329, in __init__ File "PythonCard\resource.pyc", line 45, in __init__ File "PythonCard\util.pyc", line 30, in readAndEvalFile IOError: [Errno 2] No such file or directory: 'JobRater.rsrc.py' Unfortunately I'm not sure what the correct method for using py2exe with pythonCard is so I'm not sure if I'm doing something wrong or what. This is my setup.py file: from distutils.core import setup import py2exe setup(windows=["JobRater.py"]) And then I just call it as instructed on the py2exe website: >>python setup.py py2exe Any ideas what I could be doing wrong? Below I'll paste JobRater.py and JobRater.rsrc.py just in case there's something wrong in those. Thanks, Greg JobRater.py: #!/usr/bin/python """ __version__ = "$Revision: 1.5 $" __date__ = "$Date: 2004/04/30 16:26:12 $" """ from PythonCard import model import cPickle from main import ProbData class JobRater(model.Background): def on_initialize(self, event): #get data files datafile=r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\data.p' #if find data files load them self.Jobbayes=cPickle.load(file(datafile)) unratedjobs_datafilepath=r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\data\trainingdata\unratedjobs.csv' outputfilepath=r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\batchoutput.csv' self.unratedjobsfile=file(unratedjobs_datafilepath) self.newlyratedjobsoutfile=file(r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\newlyratedjobs.csv','a') self.alljobslist=self.unratedjobsfile.readlines() self.updatejobdesc() def on_btngood_mouseClick(self,event): self.Jobbayes.train_from_an_example(True,self.job) self.newlyratedjobsoutfile.write('YES'+','+self.job) self.updatejobdesc() event.Skip() def on_btnbad_mouseClick(self,event): self.Jobbayes.train_from_an_example(False,self.job) self.newlyratedjobsoutfile.write('NO'+','+self.job) self.updatejobdesc() event.Skip() def on_btnExplain_mouseClick(self,event): self.components["txtjobdesc"].text=self.Jobbayes.explainrating(self.job) event.Skip() def on_txtjobdesc_mouseClick(self,event): self.updatejobdesc() event.Skip() def updatejobdesc(self): self.job=self.alljobslist.pop() self.components["txtjobdesc"].text=self.job self.components["lblpercentrating"].text=str(round(self.Jobbayes.ratenewjob(self.job)*100,2))+'%' def on_mnuExit_select(self, event): self.close() def on_close(self, event): #save trained data cPickle.dump(self.Jobbayes,file(r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\data.p','w')) event.skip() if __name__ == '__main__': app = model.Application(JobRater) app.MainLoop() JobRater.rsrc.py: {'application':{'type':'Application', 'name':'Template', 'backgrounds': [ {'type':'Background', 'name':'jobview', 'title':'Job Rating', 'position':(271, 69), 'size':(600, 800), 'menubar': {'type':'MenuBar', 'menus': [ {'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ {'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit', 'command':'exit', }, ] }, ] }, 'components': [ {'type':'Button', 'name':'btnExplain', 'position':(337, 14), 'size':(115, 23), 'font':{'style': 'italic', 'faceName': 'Times New Roman', 'family': 'sansSerif', 'size': 8}, 'label':'Explain this rating', }, {'type':'StaticText', 'name':'lblpercentrating', 'position':(227, 9), 'size':(99, 37), 'alignment':'center', 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 20}, }, {'type':'StaticText', 'name':'StaticText2', 'position':(6, 18), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 10}, 'text':'Probability that this is a good job is ', }, {'type':'StaticText', 'name':'StaticText1', 'position':(63, 676), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 18}, 'text':'Training:', }, {'type':'Button', 'name':'btnbad', 'position':(181, 661), 'size':(100, 80), 'backgroundColor':(255, 0, 0), 'font':{'faceName': 'Arial Black', 'family': 'sansSerif', 'size': 8}, 'label':'Rate As Bad', }, {'type':'Button', 'name':'btngood', 'position':(281, 661), 'size':(-1, 80), 'backgroundColor':(0, 255, 0), 'font':{'faceName': 'Arial Black', 'family': 'sansSerif', 'size': 8}, 'label':'Rate As Good', }, {'type':'TextArea', 'name':'txtjobdesc', 'position':(0, 60), 'size':(590, 602), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 12}, }, ] # end components } # end background ] # end backgrounds } } |
From: <gre...@gm...> - 2004-11-29 18:58:58
|
Hey guys, I tried sending this yesterday, I'm not sure why it didn't go thr= ough. ---------- Forwarded message ---------- From: Gregory Pi=F1ero <gre...@gm...> Date: Sun, 28 Nov 2004 17:37:04 -0500 Subject: Using py2exe with pythoncard To: pyt...@li... Hi everyone, I'm trying to use py2exe on a small pythoncard app I made but when I try to run the exe it says errors occured and in the log file it says: Traceback (most recent call last): File "JobRater.py", line 60, in ? File "PythonCard\model.pyc", line 329, in __init__ File "PythonCard\resource.pyc", line 45, in __init__ File "PythonCard\util.pyc", line 30, in readAndEvalFile IOError: [Errno 2] No such file or directory: 'JobRater.rsrc.py' Unfortunately I'm not sure what the correct method for using py2exe with pythonCard is so I'm not sure if I'm doing something wrong or what. This is my setup.py file: from distutils.core import setup import py2exe setup(windows=3D["JobRater.py"]) And then I just call it as instructed on the py2exe website: >>python setup.py py2exe Any ideas what I could be doing wrong? Below I'll paste JobRater.py and JobRater.rsrc.py just in case there's something wrong in those. Thanks, Greg JobRater.py: #!/usr/bin/python """ __version__ =3D "$Revision: 1.5 $" __date__ =3D "$Date: 2004/04/30 16:26:12 $" """ from PythonCard import model import cPickle from main import ProbData class JobRater(model.Background): def on_initialize(self, event): #get data files datafile=3Dr'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\data.p' #if find data files load them self.Jobbayes=3DcPickle.load(file(datafile)) unratedjobs_datafilepath=3Dr'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\data\trainingdata\unratedjobs.csv' outputfilepath=3Dr'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\batchoutput.csv' self.unratedjobsfile=3Dfile(unratedjobs_datafilepath) self.newlyratedjobsoutfile=3Dfile(r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\newlyratedjobs.csv','a') self.alljobslist=3Dself.unratedjobsfile.readlines() self.updatejobdesc() def on_btngood_mouseClick(self,event): self.Jobbayes.train_from_an_example(True,self.job) self.newlyratedjobsoutfile.write('YES'+','+self.job) self.updatejobdesc() event.Skip() def on_btnbad_mouseClick(self,event): self.Jobbayes.train_from_an_example(False,self.job) self.newlyratedjobsoutfile.write('NO'+','+self.job) self.updatejobdesc() event.Skip() def on_btnExplain_mouseClick(self,event): self.components["txtjobdesc"].text=3Dself.Jobbayes.explainrating(se= lf.job) event.Skip() def on_txtjobdesc_mouseClick(self,event): self.updatejobdesc() event.Skip() def updatejobdesc(self): self.job=3Dself.alljobslist.pop() self.components["txtjobdesc"].text=3Dself.job self.components["lblpercentrating"].text=3Dstr(round(self.Jobbayes.= ratenewjob(self.job)*100,2))+'%' def on_mnuExit_select(self, event): self.close() def on_close(self, event): #save trained data cPickle.dump(self.Jobbayes,file(r'C:\Documents and Settings\Gregory\My Documents\1JHUClasses\605.445.71 (AI)\Project\src\data.p','w')) event.skip() if __name__ =3D=3D '__main__': app =3D model.Application(JobRater) app.MainLoop() JobRater.rsrc.py: {'application':{'type':'Application', 'name':'Template', 'backgrounds': [ {'type':'Background', 'name':'jobview', 'title':'Job Rating', 'position':(271, 69), 'size':(600, 800), 'menubar': {'type':'MenuBar', 'menus': [ {'type':'Menu', 'name':'menuFile', 'label':'&File', 'items': [ {'type':'MenuItem', 'name':'menuFileExit', 'label':'E&xit', 'command':'exit', }, ] }, ] }, 'components': [ {'type':'Button', 'name':'btnExplain', 'position':(337, 14), 'size':(115, 23), 'font':{'style': 'italic', 'faceName': 'Times New Roman', 'family': 'sansSerif', 'size': 8}, 'label':'Explain this rating', }, {'type':'StaticText', 'name':'lblpercentrating', 'position':(227, 9), 'size':(99, 37), 'alignment':'center', 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 20}, }, {'type':'StaticText', 'name':'StaticText2', 'position':(6, 18), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 10}, 'text':'Probability that this is a good job is ', }, {'type':'StaticText', 'name':'StaticText1', 'position':(63, 676), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 18}, 'text':'Training:', }, {'type':'Button', 'name':'btnbad', 'position':(181, 661), 'size':(100, 80), 'backgroundColor':(255, 0, 0), 'font':{'faceName': 'Arial Black', 'family': 'sansSerif', 'size': 8}, 'label':'Rate As Bad', }, {'type':'Button', 'name':'btngood', 'position':(281, 661), 'size':(-1, 80), 'backgroundColor':(0, 255, 0), 'font':{'faceName': 'Arial Black', 'family': 'sansSerif', 'size': 8}, 'label':'Rate As Good', }, {'type':'TextArea', 'name':'txtjobdesc', 'position':(0, 60), 'size':(590, 602), 'font':{'faceName': 'Microsoft Sans Serif', 'family': 'sansSerif', 'size': 12}, }, ] # end components } # end background ] # end backgrounds } } |
From: Kevin A. <al...@se...> - 2004-11-29 21:29:19
|
On Nov 28, 2004, at 2:37 PM, Gregory Pi=F1ero wrote: > Hi everyone, > > I'm trying to use py2exe on a small pythoncard app I made but when I > try to run the exe it says errors occured and in the log file it says: > > Traceback (most recent call last): > File "JobRater.py", line 60, in ? > File "PythonCard\model.pyc", line 329, in __init__ > File "PythonCard\resource.pyc", line 45, in __init__ > File "PythonCard\util.pyc", line 30, in readAndEvalFile > IOError: [Errno 2] No such file or directory: 'JobRater.rsrc.py' > > Unfortunately I'm not sure what the correct method for using py2exe > with pythonCard is so I'm not sure if I'm doing something wrong or > what. This is my setup.py file: > > from distutils.core import setup > import py2exe > > setup(windows=3D["JobRater.py"]) > > And then I just call it as instructed on the py2exe website: > >>> python setup.py py2exe > > Any ideas what I could be doing wrong? Below I'll paste JobRater.py > and JobRater.rsrc.py just in case there's something wrong in those. > > Thanks, > > Greg > You need to specifically import the component modules that you use in=20 your resource file, but your initial problem is that you need to=20 included the .rsrc.py and any other data files you use either by=20 manually copying them into the directory or just including them in the=20= py2exe data files list. If you look at the minimalStandalone sample=20 you'll see setup.py ... from distutils.core import setup import py2exe setup( name =3D "minimal", console =3D ["minimal.py"], data_files =3D [ (".", ["readme.txt", "minimal.rsrc.py"]) ] ) ka |
From: <gre...@gm...> - 2004-12-01 19:40:53
|
On Mon, 29 Nov 2004 13:29:09 -0800, Kevin Altis <al...@se...> wr= ote: > On Nov 28, 2004, at 2:37 PM, Gregory Pi=F1ero wrote: >=20 >=20 >=20 > > Hi everyone, > > > > I'm trying to use py2exe on a small pythoncard app I made but when I > > try to run the exe it says errors occured and in the log file it says: > > > > Traceback (most recent call last): > > File "JobRater.py", line 60, in ? > > File "PythonCard\model.pyc", line 329, in __init__ > > File "PythonCard\resource.pyc", line 45, in __init__ > > File "PythonCard\util.pyc", line 30, in readAndEvalFile > > IOError: [Errno 2] No such file or directory: 'JobRater.rsrc.py' > > > > Unfortunately I'm not sure what the correct method for using py2exe > > with pythonCard is so I'm not sure if I'm doing something wrong or > > what. This is my setup.py file: > > > > from distutils.core import setup > > import py2exe > > > > setup(windows=3D["JobRater.py"]) > > > > And then I just call it as instructed on the py2exe website: > > > >>> python setup.py py2exe > > > > Any ideas what I could be doing wrong? Below I'll paste JobRater.py > > and JobRater.rsrc.py just in case there's something wrong in those. > > > > Thanks, > > > > Greg > > >=20 > You need to specifically import the component modules that you use in > your resource file, but your initial problem is that you need to > included the .rsrc.py and any other data files you use either by > manually copying them into the directory or just including them in the > py2exe data files list. If you look at the minimalStandalone sample > you'll see setup.py ... >=20 > from distutils.core import setup > import py2exe >=20 > setup( name =3D "minimal", > console =3D ["minimal.py"], > data_files =3D [ (".", ["readme.txt", "minimal.rsrc.py"]) ] > ) >=20 > ka >=20 > ------------------------------------------------------- > 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 > |
From: <gre...@gm...> - 2004-12-01 19:44:41
|
Hey Kevin, I'm still getting a new problem now. Per your example I changed my setup file to: from distutils.core import setup import py2exe setup( name =3D "JobRater", console =3D ["JobRater.py"], data_files =3D [ (".", ["JobRater.rsrc.py"]) ] ) Now I'm getting this error when I try to run it: Traceback (most recent call last): File "JobRater.py", line 65, in ? File "PythonCard\model.pyc", line 329, 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 Any ideas? Thanks, Greg On Wed, 1 Dec 2004 14:40:46 -0500, Gregory Pi=F1ero <gre...@gm...> = wrote: > On Mon, 29 Nov 2004 13:29:09 -0800, Kevin Altis <al...@se...> = wrote: >=20 >=20 > > On Nov 28, 2004, at 2:37 PM, Gregory Pi=F1ero wrote: > > > > > > > > > Hi everyone, > > > > > > I'm trying to use py2exe on a small pythoncard app I made but when I > > > try to run the exe it says errors occured and in the log file it says= : > > > > > > Traceback (most recent call last): > > > File "JobRater.py", line 60, in ? > > > File "PythonCard\model.pyc", line 329, in __init__ > > > File "PythonCard\resource.pyc", line 45, in __init__ > > > File "PythonCard\util.pyc", line 30, in readAndEvalFile > > > IOError: [Errno 2] No such file or directory: 'JobRater.rsrc.py' > > > > > > Unfortunately I'm not sure what the correct method for using py2exe > > > with pythonCard is so I'm not sure if I'm doing something wrong or > > > what. This is my setup.py file: > > > > > > from distutils.core import setup > > > import py2exe > > > > > > setup(windows=3D["JobRater.py"]) > > > > > > And then I just call it as instructed on the py2exe website: > > > > > >>> python setup.py py2exe > > > > > > Any ideas what I could be doing wrong? Below I'll paste JobRater.py > > > and JobRater.rsrc.py just in case there's something wrong in those. > > > > > > Thanks, > > > > > > Greg > > > > > > > You need to specifically import the component modules that you use in > > your resource file, but your initial problem is that you need to > > included the .rsrc.py and any other data files you use either by > > manually copying them into the directory or just including them in the > > py2exe data files list. If you look at the minimalStandalone sample > > you'll see setup.py ... > > > > from distutils.core import setup > > import py2exe > > > > setup( name =3D "minimal", > > console =3D ["minimal.py"], > > data_files =3D [ (".", ["readme.txt", "minimal.rsrc.py"]) ] > > ) > > > > ka > > > > ------------------------------------------------------- > > 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 > > > |
From: Ruben M. <rmc...@ya...> - 2004-12-01 20:35:24
|
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 |
From: <gre...@gm...> - 2004-12-01 21:11:58
|
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 > |
From: <jon...@wa...> - 2004-12-03 16:31:57
|
I found a script that will out-put the PythonCard components of a resou= rce file. I did not write it, so I can't take credit for it. I only updated it f= or 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, fromlis= t)) __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 refer= red 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])+" impor= t "+".".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 = |
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 |
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2005-01-05 15:09:00
|
On Mon, 3 Jan 2005 11:36:01 +0530, Luanne Coutinho wrote: >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? It looks like you're missing "button" from the list of imported PythonCard components: from PythonCard.Components import button I forgot to include the staticline component a couple of days ago when using the McMillan Installer and got a virtually identical traceback when running the app. Neil |
From: Luanne C. <lua...@gm...> - 2005-01-06 04:42:16
|
I do have the button imported- this is my setup.py #!/usr/bin/python """ __version__ = "$Revision: 1.10 $" __date__ = "$Date: 2004/04/24 22:13:31 $" """ from distutils.core import setup from PythonCard.components import textfield,statictext,button import py2exe setup(name="AutoPhoto", console=["AutoPhoto.py"], data_files=[(".",["AutoPhoto.rsrc.py"])] ) Thanks, Luanne On Wed, 5 Jan 2005 15:10:21 +0000, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX wrote: > On Mon, 3 Jan 2005 11:36:01 +0530, Luanne Coutinho wrote: > > >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? > > It looks like you're missing "button" from the list of imported > PythonCard components: > > from PythonCard.Components import button > > I forgot to include the staticline component a couple of days ago when > using the McMillan Installer and got a virtually identical traceback when > running the app. > > Neil > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- http://ladyluanne.blogspot.com |
From: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX - 2005-01-10 08:10:44
|
On Thu, 6 Jan 2005 10:12:09 +0530, Luanne Coutinho wrote: >I do have the button imported- this is my setup.py <snip> >from distutils.core import setup >from PythonCard.components import textfield,statictext,button >import py2exe In which case, my brief attempt at helping has come to a grinding halt :-( I was going to try out py2exe this weekend on one of my PythonCard projects to see if I could replicate your problem here, but for some reason the py2exe installer falls over on my XP machine (double-clicking the self-installing exe brings up an illegal instruction in the 16-bit DOS subsystem!). Neil |
From: Luanne C. <lua...@gm...> - 2005-01-14 04:12:33
|
Is there anything else I can do to get this working? Thanks Luanne On Mon, 10 Jan 2005 08:13:12 +0000, XXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX wrote: > > > On Thu, 6 Jan 2005 10:12:09 +0530, Luanne Coutinho wrote: > > >I do have the button imported- this is my setup.py > <snip> > >from distutils.core import setup > >from PythonCard.components import textfield,statictext,button > >import py2exe > > In which case, my brief attempt at helping has come to a grinding halt :-( > > I was going to try out py2exe this weekend on one of my PythonCard > projects to see if I could replicate your problem here, but for some > reason the py2exe installer falls over on my XP machine (double-clicking > the self-installing exe brings up an illegal instruction in the 16-bit > DOS subsystem!). > > Neil > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- http://ladyluanne.blogspot.com |
From: Ruben M. <rmc...@ya...> - 2005-01-17 22:06:48
|
Luanne, the line: from PythonCard.components import textfield, statictext, button should be in your acual aplication file, not on the setup.py. I believe there is a minimal sample that shows this in the samples directory. -Ruben --- Luanne Coutinho <lua...@gm...> wrote: > I do have the button imported- this is my setup.py > > #!/usr/bin/python > > """ > __version__ = "$Revision: 1.10 $" > __date__ = "$Date: 2004/04/24 22:13:31 $" > """ > > from distutils.core import setup > from PythonCard.components import > textfield,statictext,button > import py2exe > > setup(name="AutoPhoto", > console=["AutoPhoto.py"], > data_files=[(".",["AutoPhoto.rsrc.py"])] > ) > > > Thanks, > Luanne > > > On Wed, 5 Jan 2005 15:10:21 +0000, XXXXXXXXXXX > XXXXXXXXXXXXXXXXXXXXXXXXXX wrote: > > On Mon, 3 Jan 2005 11:36:01 +0530, Luanne Coutinho > wrote: > > > > >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? > > > > It looks like you're missing "button" from the > list of imported > > PythonCard components: > > > > from PythonCard.Components import button > > > > I forgot to include the staticline component a > couple of days ago when > > using the McMillan Installer and got a virtually > identical traceback when > > running the app. > > > > Neil > > > > > ------------------------------------------------------- > > The SF.Net email is sponsored by: Beat the > post-holiday blues > > Get a FREE limited edition SourceForge.net t-shirt > from ThinkGeek. > > It's fun and FREE -- well, > almost....http://www.thinkgeek.com/sfshirt > > _______________________________________________ > > Pythoncard-users mailing list > > Pyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > > > > -- > http://ladyluanne.blogspot.com > > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the > post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt > from ThinkGeek. > It's fun and FREE -- well, > almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com |
From: Luanne C. <lua...@gm...> - 2005-01-19 05:06:55
|
It worked !!! Very stupid of me...thanks for all your help. -Luanne On Mon, 17 Jan 2005 14:06:38 -0800 (PST), Ruben Marquez <rmc...@ya...> wrote: > Luanne, the line: > > from PythonCard.components import textfield, > statictext, button > > should be in your acual aplication file, not on the > setup.py. I believe there is a minimal sample that > shows this in the samples directory. > > -Ruben > > --- Luanne Coutinho <lua...@gm...> wrote: > > > I do have the button imported- this is my setup.py > > > > #!/usr/bin/python > > > > """ > > __version__ = "$Revision: 1.10 $" > > __date__ = "$Date: 2004/04/24 22:13:31 $" > > """ > > > > from distutils.core import setup > > from PythonCard.components import > > textfield,statictext,button > > import py2exe > > > > setup(name="AutoPhoto", > > console=["AutoPhoto.py"], > > data_files=[(".",["AutoPhoto.rsrc.py"])] > > ) > > > > > > Thanks, > > Luanne > > > > > > On Wed, 5 Jan 2005 15:10:21 +0000, XXXXXXXXXXX > > XXXXXXXXXXXXXXXXXXXXXXXXXX wrote: > > > On Mon, 3 Jan 2005 11:36:01 +0530, Luanne Coutinho > > wrote: > > > > > > >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? > > > > > > It looks like you're missing "button" from the > > list of imported > > > PythonCard components: > > > > > > from PythonCard.Components import button > > > > > > I forgot to include the staticline component a > > couple of days ago when > > > using the McMillan Installer and got a virtually > > identical traceback when > > > running the app. > > > > > > Neil > > > > > > > > > ------------------------------------------------------- > > > The SF.Net email is sponsored by: Beat the > > post-holiday blues > > > Get a FREE limited edition SourceForge.net t-shirt > > from ThinkGeek. > > > It's fun and FREE -- well, > > almost....http://www.thinkgeek.com/sfshirt > > > _______________________________________________ > > > Pythoncard-users mailing list > > > Pyt...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > > > > > > > > -- > > http://ladyluanne.blogspot.com > > > > > > > ------------------------------------------------------- > > The SF.Net email is sponsored by: Beat the > > post-holiday blues > > Get a FREE limited edition SourceForge.net t-shirt > > from ThinkGeek. > > It's fun and FREE -- well, > > almost....http://www.thinkgeek.com/sfshirt > > _______________________________________________ > > Pythoncard-users mailing list > > Pyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > > > > > __________________________________ > Do you Yahoo!? > Meet the all-new My Yahoo! - Try it today! > http://my.yahoo.com > > ------------------------------------------------------- > The SF.Net email is sponsored by: Beat the post-holiday blues > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users > -- http://ladyluanne.blogspot.com |
From: Thomas H. <th...@py...> - 2004-12-02 21:02:21
|
Gregory Piñero <gre...@gm...> writes: > 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? Yes, you need the whole folder. Maybe in the future py2exe will allow to create real single file executables for simple cases (not too many python extension modules), but it will probably never happen for wxPython apps, where the wxPython dll (dlls?) are needed as well. OTOH, there's a recipe in the py2exe wiki which creates a single exe-file which at runtime unpacks all the stuff, and cleans up afterwards. Personally, I never found that very nice. Here's the link http://starship.python.net/crew/theller/moin.cgi/SingleFileExecutable Thomas |