From: Mark H. <mha...@sk...> - 2012-02-01 00:39:54
|
On 1/02/2012 11:31 AM, hari jayaram wrote: > Thanks for your email Mark.. > > 1) How do I add the library.zip to the pythonpath. What is the path of the app? > Is it something like > sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),"library.zip")) Easiest way is probably just to add it to the PYTHONPATH env var for the child. > > Or should I use something like here http://www.py2exe.org/index.cgi/WhereAmI > > > 2) I couldnt find out how to add the includes directive in my > setup.py. Sorry I am confused since all the online examples seem to > have a different syntax >>> from distutils.core import setup >>> import py2exe >>> import gridder >>> setup(console=['gzilla.py'] ) The syntax is a little strained - something like: >>> setup(console=['gzilla.py'], options = {"py2exe": {"includes": "mod1, mod2"}}) inside that py2exe dict is where other py2exe options go - like "excludes", "dll_excludes" etc. HTH, Mark > > > Hari > > On Tue, Jan 31, 2012 at 7:08 PM, Mark Hammond<ski...@gm...> wrote: >> On 1/02/2012 10:57 AM, hari jayaram wrote: >>> >>> Hello All, >>> >>> I have a wxpython GUI application that I am trying to make a >>> standalone exe executable for. >>> During user interaction the GUI creates a python script. >>> This script is then run using "subprocess.popen" with the arguments >>> ["python" ,"script.py"]. >>> >>> When I run the exe file created , using the wxpython GUI I >>> successfully create the script which is then run by clicking the run >>> script button in the GUI . >>> This calls the subprocess module . However at this stage I get a >>> >>> "ImportError no module named gridder" >>> >>> I have added a import gridder to the py2exe script and the wxpython >>> code . I even made sure I create some dummy objects with the gridder >>> module classes in my GUI code. >>> >>> When I check the library.zip , I see the gridder module stored there. >>> The build log also shows that py2exe is byte-compiling the gridder >>> module from site-packages/gridder directory. >>> >>> >>> Despite this does someone know why the subprocess script throws an >>> ImportError saying no module gridder. What can I get to have the >>> subprocess module bundled with the exe import and use the module >>> bundled in the library.zip >> >> >> You probably just need to ensure library.zip (the file, not the directory >> holding the file) is on the PYTHONPATH in the child process. You could >> probably even add this module to the "includes" in your py2exe script and it >> should be scanned and further "sub-imports" will automagically be included. >> >> Mark >> >>> >>> >>> Thanks >>> >>> Hari >>> >>> ################### >>> my setup_file is simple: >>> ################### >>> >>> from distutils.core import setup >>> import py2exe >>> import gridder >>> setup(console=['gzilla.py']) >>> >>> >>> ############## >>> A sample script written by the application >>> ################ >>> >>> #!/usr/bin/python >>> import gridder >>> from gridder import masterplate,plate,component,buffercomponent >>> mp = masterplate.Masterplate(2000,96) >>> p11 = plate.Plate("A7","H7",mp) >>> p10 = plate.Plate("A6","H6",mp) >>> p13 = plate.Plate("A9","H9",mp) >>> p12 = plate.Plate("A8","H8",mp) >>> p15 = plate.Plate("A11","H11",mp) >>> p14 = plate.Plate("A10","H10",mp) >>> p17 = plate.Plate("A1","H12",mp) >>> p16 = plate.Plate("A12","H12",mp) >>> p1 = plate.Plate("A1","D6",mp) >>> p3 = plate.Plate("E1","H6",mp) >>> p2 = plate.Plate("A7","D12",mp) >>> p5 = plate.Plate("A1","H1",mp) >>> p4 = plate.Plate("E7","H12",mp) >>> p7 = plate.Plate("A3","H3",mp) >>> p6 = plate.Plate("A2","H2",mp) >>> p9 = plate.Plate("A5","H5",mp) >>> p8 = plate.Plate("A4","H4",mp) >>> c2 = component.Component("peg2kmme" , 50,10000000) >>> c3 = component.Component("peg5kmme" , 50,10000000) >>> c4 = component.Component("peg2k" , 50,10000000) >>> c5 = component.Component("peg3350" , 50,10000000) >>> c6 = component.Component("peg4k" , 50,10000000) >>> c7 = component.Component("peg8k" , 50,10000000) >>> c8 = component.Component("glycerol" , 50,10000000) >>> c9 = component.Component("hepesph7p5" , 1,10000000) >>> c10 = component.Component("amsulfate4m" , 4,10000000) >>> p17.push_component_uniform_to_masterplate(c9,0.1) >>> p7.gradientlist_along_y(c4,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p8.gradientlist_along_y(c5,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p9.gradientlist_along_y(c6,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p10.gradientlist_along_y(c7,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p11.gradientlist_along_y(c2,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p12.gradientlist_along_y(c3,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p13.gradientlist_along_y(c4,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p14.gradientlist_along_y(c5,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p15.gradientlist_along_y(c6,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p16.gradientlist_along_y(c7,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p2.push_component_uniform_to_masterplate(c8,7.5) >>> p17.push_component_rowlist(c8,12.5,["E"]) >>> p17.push_component_rowlist(c8,15,["F","G","H"]) >>> p17.push_component_rowlist(c10,0.2,["A","B","C","D"]) >>> p3.push_component_uniform_to_masterplate(c10,0.2) >>> p4.push_component_uniform_to_masterplate(c10,0.1) >>> p5.gradientlist_along_y(c2,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> p6.gradientlist_along_y(c3,[30,27.5,25,22.5,30,27.5,25,22.5]) >>> water = component.Component("100.00 % Water",100,100000) >>> p17.fill_water(water) >>> p7.fill_water(water) >>> p8.fill_water(water) >>> p9.fill_water(water) >>> p10.fill_water(water) >>> p11.fill_water(water) >>> p12.fill_water(water) >>> p13.fill_water(water) >>> p14.fill_water(water) >>> p15.fill_water(water) >>> p16.fill_water(water) >>> p2.fill_water(water) >>> p3.fill_water(water) >>> p4.fill_water(water) >>> p5.fill_water(water) >>> p6.fill_water(water) >>> mp.printwellinfo() >>> mp.makefileforformulatrix(r"C:\Users\hari.jayaram\Desktop\test.dl.txt") >>> mp.writepdf(r"C:\Users\hari.jayaram\Desktop\test") >>> >>> mp.makefileforhamilton(r"C:\Users\hari.jayaram\Desktop\test-hamilton.csv",1) >>> >>> ############## >>> Code that calls the script once it is written >>> ############### >>> os.chmod((os.path.join(self.GetParent().dirtowriteto,"%s_scr.py" % >>> >>> str(self.GetParent().FindWindowByName("mpanel").file_name_text.GetValue()))),0755) >>> subp_status = >>> subprocess.Popen(["python",os.path.join(self.GetParent().dirtowriteto,"%s_scr.py" >>> % >>> str(self.GetParent().FindWindowByName("mpanel").file_name_text.GetValue()))],shell=False,stderr=subprocess.PIPE,stdout=subprocess.PIPE) >>> mystdout,mystderr = subp_status.communicate() >>> >>> >>> ------------------------------------------------------------------------------ >>> Keep Your Developer Skills Current with LearnDevNow! >>> The most comprehensive online learning library for Microsoft developers >>> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >>> Metro Style Apps, more. Free future releases when you subscribe now! >>> http://p.sf.net/sfu/learndevnow-d2d >>> _______________________________________________ >>> Py2exe-users mailing list >>> Py2...@li... >>> https://lists.sourceforge.net/lists/listinfo/py2exe-users >> >> |