Jump to content

py2exe


DingleBerries

Recommended Posts

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'}] )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...