I am having trouble compiling an exe. I tried both py2exe and cxfreeze with similar results, I made an exe but it didn't work. I figured out that I needed to send the image files and sounds with it (should have thought of that to begin with). Now that I added the code for that I get a syntax error:

>c:\python26\python.exe setup.py py2exe
SyntaxError:
data_files=("images\menu_items",
^

Here is a copy of the code from my setup file.

from distutils.core import setup
import glob
import py2exe

setup(console=["TargetPracticeV11.pyw",
    data_files=("images\menu_items",
               [glob.glob("images\menu_items\\*.gif"), glob.glob("images\menu_items\\*.png"), glob.glob("images\menu_items\\*.jpg")]),
              ("images\menu_items\\buttons",
               [glob.glob("images\menu_items\\buttons\\*.gif"), glob.glob("images\menu_items\\buttons\\*.png")]),
              ("images\\level_objects",
               [glob.glob("images\level_objects\\*.gif"), glob.glob("images\level_objects\\*.png")]),
              ("sounds",
               [glob.glob("sounds\\*.wav"), glob.glob("sounds\\*.mid"), glob.glob("sounds\\*.mp3")],
                )

So I do understand that what I had before was pretty incomplete, I found gui2exe which isn't working properly for me either. I ended up copying the setup file and making a few changes in order to copy microsoft visual studio .dlls. No success, the files don't make it through.

from distutils.core import setup
from py2exe.build_exe import py2exe

import glob
import os
import zlib
import shutil

# Remove the build folder
shutil.rmtree("build", ignore_errors=True)

mfcfiles = [os.path.join("C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\redist\\x86\\", i) for i in ["mfc90.dll", "mfc90u.dll", "mfcm90.dll", "mfcm90u.dll", "Microsoft.VC90.MFC.manifest"]]

mcfdata = [(".\Microsoft.VC90.CRT", mfcfiles)
           ]
class Target(object):
    """ A simple class that holds information on our executable file. """
    def __init__(self, **kw):
        """ Default class constructor. Update as you need. """
        self.__dict__.update(kw)
        

# Ok, let's explain why I am doing that.
# Often, data_files, excludes and dll_excludes (but also resources)
# can be very long list of things, and this will clutter too much
# the setup call at the end of this file. So, I put all the big lists
# here and I wrap them using the textwrap module.

data_files = [mcfdata,
              ('.\sounds', ['C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\boom.wav',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\bsound1.wav',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\bsound2.wav',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\bsound3.wav',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\error.wav',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\fanfare.mid',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\kije.mid',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\pavane.mid',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\Pittoresco.mp3',
                            'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\sounds\\venus.mid']),
              ('.', ['C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\highscores.txt',
                     'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\Name Archive.txt',
                     'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\playernames.txt',
                     'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\savestate.txt']),
              ('.\images\menu_items\buttons', ['C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\back_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\back_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\cancel_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\cancel_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\continue_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\continue_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\highscore_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\highscore_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\inst_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\inst_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\menu_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\menu_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\menu_button_g_m.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\menu_button_m.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\music_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\music_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\newplayer_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\newplayer_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\next_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\next_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\play_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\play_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\quit_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\quit_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\redo_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\redo_button_g.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\save_button.gif',
                                               'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\buttons\\save_button_g.gif']),
              ('.\images\level_objects', ['C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\ball.gif',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\bg.gif',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\block.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\block1.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\cannon.gif',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\crosshair.gif',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\extendedblock.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\extendedblock1.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\floor.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\largeblock.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\largeblock_r.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\largeblock1.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\slow.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\spring.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\spring1.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\springS.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\target.png',
                                          'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\level_objects\\wheel.gif']),
              ('.\images\menu_items', ['C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\bg.jpg',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\cursor1.gif',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\instructions.gif',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\main.png',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\menubar.png',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\menubar_closed.png',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\menubar_closed_g.png',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\menubar_g.png',
                                       'C:\\Users\\Owner\\Documents\\COS 125 (Python)\\Project two folder\\Version 11\\images\\menu_items\\textbox.png'])]

includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
                'tk84.dll', 'msvcr90.dll']
icon_resources = []
bitmap_resources = []
other_resources = []


# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.

# No custom code added


# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D

GUI2Exe_Target_1 = Target(
    # what to build
    script = "TargetPracticeV11.py",
    icon_resources = icon_resources,
    bitmap_resources = bitmap_resources,
    other_resources = other_resources,
    dest_base = "TargetPracticeV11",    
    version = "11.0",
    company_name = "No Company",
    copyright = "No Copyrights",
    name = "Py2Exe Sample File",
    
    )

# No custom class for UPX compression or Inno Setup script

# That's serious now: we have all (or almost all) the options py2exe
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.
                    
setup(

    # No UPX or Inno Setup

    data_files = data_files,

    options = {"py2exe": {"compressed": 2, 
                          "optimize": 2,
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 1,
                          "dist_dir": "dist",
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },

    zipfile = None,
    console = [],
    windows = [GUI2Exe_Target_1],
    service = [],
    com_server = [],
    ctypes_com_server = []
    )

# This is a place where any post-compile code may go.
# You can add as much code as you want, which can be used, for example,
# to clean up your folders or to do some particular post-compilation
# actions.

# No post-compilation code added


# And we are done. That's a setup script :-D

So I have been trying to compile an executable with no real luck. I am using gui2exe, which works great... I followed the instructions from py2exe using python 2.6 or 2.7 (both are installed) which says to copy msvcr90.dll and the manifest file. In order to do this and not get an error about improper copying I had to copy the folder with all of it's files to my project folder. When I try to launch my new executable it cannot find msvcr90.dll. I debugged and found that when I try to launch the new executable instead of trying to open msvcr90.dll from the new folder it is trying to get it from the main project folder. I did follow the instructions even the bit that says to append the system path py2exe 5.2.2. I hope someone may be able to point me in the right direction.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.