Thread: py2exe problem

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0

    py2exe problem


    py2exe (0.50)
    python (2.3.3)

    running py2exe on a script, no errors thrown and an executable is made.

    Executable does not work - it runs but no results occur and no errors are thrown.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    irishtek,

    A few suggestion in no particular order:
    1. Try building the app as a console application and run it from an already open command window. See if anything is printed.
    2. Sprinkle a few print statements in the main module to confirm its actually running
    Code:
    if __name__ == "__main__":
        print "Starting..."
        #your code
        print "Stopping"
    3. Check the build logs - I use a modified standard script like this
    Code:
    # setup.py
    # Requires py2exe has been installed that matches python version
    # Run this program "python release.py py2exe" to create an executable + dlls found in
    # c:/python21/dist/gscript.
    # see http://starship.python.net/crew/theller/py2exe/ for details.
    from distutils.core import setup
    import py2exe
    import glob
    import sys
    
    rd="c:\\tester"
    
    f = open(rd+'\\pybuild.log','w')
    sys.stdout = f
    setup(
        name="GSCRIPT",
        windows=[
                    {
                        "script":rd+"\\gscript.pyw",
                        "icon_resources":[(1,rd+"\\g.ico")]
                    }
                ],
        data_files=[
                        (
                            ".",['gextension.py','pypdu.py','g.ico','w9xpopen.exe',
                            "GSCRIPT.htm",'script.template',
                            'calldll.pyd','DLPORTIO.dll',
                            'DLPORTIO.sys']
                             +glob.glob("*.gsc")
                        ),
                        (
                            "GSCRIPT_files",glob.glob(rd+"\\GSCRIPT_files\\*.gif")
                            +glob.glob(rd+"\\GSCRIPT_files\\*.jpg")
                            +glob.glob(rd+"\\GSCRIPT_files\\*.png")
                        ),
                        (
                            r"ftp", glob.glob(rd+"\\ftp\\*.*")
                        ),    
                    ],
        )
    f.close()
    to write a log file.
    I then use a batch file:
    Code:
    c:\python23\python py2exe setup.py
    notepad pybuild.log
    4. Make sure you don't just pass exceptions

    Let us know how you get on.
    not so Grim
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0
    it appears to be an issue with the image library.


    If compiled and executed from DOS I see the following error:
    Starting...
    Traceback (most recent call last):
    File "<string>", line 164, in ?
    File "<string>", line 129, in MakeText
    File "Image.pyc", line 1571, in open
    IOError: cannot identify image file


    Works fine as a py script - fails as an exe
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Location
    Tucson AZ
    Posts
    29
    Rep Power
    0
    In order to make PIL and PY2EXE work together all libraries of PIL need to be imported such as:

    import Image
    import BmpImagePlugin

    also the py2exe line needs to be:
    python setup.py py2exe -pPIL

IMN logo majestic logo threadwatch logo seochat tools logo