tags:

views:

1200

answers:

3

I've written a setup.py script for py2exe, generated an executable for my python GUI application and I have a whole bunch of files in the dist directory, including the app, w9xopen.exe and MSVCR71.dll. When I try to run the application, I get an error message that just says "see the logfile for details". The only problem is, the log file is empty.

The closest error I've seen is "The following modules appear to be missing" but I'm not using any of those modules as far as I know (especially since they seem to be of databases I'm not using) but digging up on Google suggests that these are relatively benign warnings.

I've written and packaged a console application as well as a wxpython one with py2exe and both applications have compiled and run successfully. I am using a new python toolkit called dabo, which in turn makes uses of wxpython modules so I can't figure out what I'm doing wrong. Where do I start investigating the problem since obviously the log file hasn't been too useful?

Edit 1: The python version is 2.5. py2exe is 0.6.8. There were no significant build errors. The only one was the bit about "The following modules appear to be missing..." which were non critical errors since the packages listed were ones I was definitely not using and shouldn't stop the execution of the app either. Running the executable produced a logfile which was completely empty. Previously it had an error about locales which I've since fixed but clearly something is wrong as the executable wasn't running. The setup.py file is based quite heavily on the original setup.py generated by running their "app wizard" and looking at the example that Ed Leafe and some others posted. Yes, I have a log file and it's not printing anything for me to use, which is why I'm asking if there's any other troubleshooting avenue I've missed which will help me find out what's going on.

I have even written a bare bones test application which simply produces a bare bones GUI - an empty frame with some default menu options. The code written itself is only 3 lines and the rest is in the 3rd party toolkit. Again, that compiled into an exe (as did my original app) but simply did not run. There were no error output in the run time log file either.

Edit 2: It turns out that switching from "windows" to "console" for initial debugging purposes was insightful. I've now got a basic running test app and on to compiling the real app!

The test app:

import dabo
app = dabo.dApp()
app.start()

The setup.py for test app:

import os
import sys
import glob
from distutils.core import setup
import py2exe
import dabo.icons
daboDir = os.path.split(dabo.__file__)[0]

# Find the location of the dabo icons:
iconDir = os.path.split(dabo.icons.__file__)[0]
iconSubDirs = []
def getIconSubDir(arg, dirname, fnames):
    if ".svn" not in dirname and dirname[-1] != "\\":
     icons = glob.glob(os.path.join(dirname, "*.png"))
     if icons:
      subdir = (os.path.join("resources", dirname[len(arg)+1:]), icons)
      iconSubDirs.append(subdir)
os.path.walk(iconDir, getIconSubDir, iconDir)

# locales:
localeDir = "%s%slocale" % (daboDir, os.sep)
locales = []
def getLocales(arg, dirname, fnames):
  if ".svn" not in dirname and dirname[-1] != "\\":
    mo_files = tuple(glob.glob(os.path.join(dirname, "*.mo")))
    if mo_files:
      subdir = os.path.join("dabo.locale", dirname[len(arg)+1:])
      locales.append((subdir, mo_files))
os.path.walk(localeDir, getLocales, localeDir)

data_files=[("resources", glob.glob(os.path.join(iconDir, "*.ico"))),
     ("resources", glob.glob("resources/*"))]
data_files.extend(iconSubDirs)
data_files.extend(locales)

setup(name="basicApp",
        version='0.01',
        description="Test Dabo Application",
        options={"py2exe": {
                "compressed": 1, "optimize": 2, "bundle_files": 1,
                "excludes": ["Tkconstants","Tkinter","tcl", 
                "_imagingtk", "PIL._imagingtk",
                "ImageTk", "PIL.ImageTk", "FixTk", "kinterbasdb", 
                "MySQLdb", 'Numeric', 'OpenGL.GL', 'OpenGL.GLUT',
                'dbGadfly', 'email.Generator', 
                'email.Iterators', 'email.Utils', 'kinterbasdb', 
                'numarray', 'pymssql', 'pysqlite2', 'wx.BitmapFromImage'], 
                "includes": ["encodings", "locale", "wx.gizmos","wx.lib.calendar"]}},
        zipfile=None,
        windows=[{'script':'basicApp.py'}], 
        data_files=data_files
)
A: 

What's the full error message? Is there a stack track or anything?

Jon Cage
+1  A: 

You may need to fix log handling first, this URL may help.

Later you may look for answer here.

My answer is very general because you didn't give any more specific info (like py2exe/python version, py2exe log, other used 3rd party libraries).

Tupteq
Thanks for the link...just wondering about this part: In order to override py2exe's default behavior, all you need to do is redirect sys.stderr (and possibly sys.stdout) to something of your making.Where do I actually put this..?
TheObserver
+1  A: 

See http://www.wxpython.org/docs/api/wx.App-class.html for wxPyton's App class initializer. If you want to run the app from a console and have stderr print to there, then supply False for the redirect argument. Otherwise, if you just want a window to pop up, set redirect to True and filename to None.

Jeremy Brown