DingleBerries Posted February 2, 2009 Share Posted February 2, 2009 I am new to python and this isnt my code, but when i try to compile it with py2exe i get the .exe and the libaries, dlls ect. The problem is that i will not run across multiple systems, i.e. those with out python installed. Is there an easier way? Here is the code and thank you in advance: import os,shutil exts = [".txt",".doc",".docx",".xls",".xlsx",".ppt",".pptx"] startpath = "C:\\Documents and Settings\\" def find(none, directory, filenames): for file in filenames: for ext in exts: if file.endswith(ext): fullfile = os.path.join(directory,file) try: shutil.copy(fullfile,file) except IOError: pass # access denied os.path.walk(startpath,find, None) Quote Link to comment Share on other sites More sharing options...
Bit Hunter Posted February 2, 2009 Share Posted February 2, 2009 There must be a parameter you can pass to py2exe, that will embed the runtime in the application. Quote Link to comment Share on other sites More sharing options...
DingleBerries Posted February 2, 2009 Author Share Posted February 2, 2009 There must be a parameter you can pass to py2exe, that will embed the runtime in the application. Like this? from distutils.core import setup import py2exe setup(console=['SCRIPTHERE.py']) If so, that is how i did it. Are there other runtimes i need to include? Quote Link to comment Share on other sites More sharing options...
Jonnycake Posted February 2, 2009 Share Posted February 2, 2009 The computer you run it on also has to have certain dlls. The setup script should give you the message of what dlls it depends on that you might need to send along with the executable. My guess is that's the problem. Quote Link to comment Share on other sites More sharing options...
DingleBerries Posted February 2, 2009 Author Share Posted February 2, 2009 The computer you run it on also has to have certain dlls. The setup script should give you the message of what dlls it depends on that you might need to send along with the executable. My guess is that's the problem. I thought that too, but most of the dlls are in every windows installation. It was late so ill try again this morning. Quote Link to comment Share on other sites More sharing options...
Zimmer Posted February 2, 2009 Share Posted February 2, 2009 Let's make it easy for you dingle berries Click Here Then click on the third link and read. ;) From http://www.python-forum.org/pythonforum/vi...f=17&t=2345 Py2Exe version 6.3 setup file for console programs. # If this is a windows GUI application replace the last line with # windows = [{"script": 'myFile.py'}] ) # # Enter the file name of your own .py code file in the last line, lets say it's test1.py # so the last line should be: console = [{"script": 'test1.py'}] ) # then save this program as p2e_test1.py to the same directory where your code file is located # Now run p2e_test1.py ... # # Two subfolders will be created called build and dist. # The dist folder contains your .exe file, MSVCR71.dll and w9xpopen.exe (needed for os.popen() only) # Your .exe file contains your byte code, all needed modules and the Python interpreter. # The MSVCR71.dll can be distributed, but is often already in the system32 folder. # The build folder can be deleted. from distutils.core import setup import py2exe import sys # no arguments if len(sys.argv) == 1: sys.argv.append("py2exe") # creates a standalone .exe file, no zip files setup( options = {"py2exe": {"compressed": 1, "optimize": 2, "ascii": 1, "bundle_files": 1}}, zipfile = None, # replace myFile.py with your own code filename here ... console = [{"script": 'MyFile.py'}] ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.