0

I have an application which I am trying to pack it with py2exe.

This application fisrt runs some computation operations, then output the results in a dialog.

When I run it in Python, the code works just fine, and the dialog and other components are displayed as I expected.

Then I used Py2exe to pack it into a .exe file, and run it. The conversion goes well without error report, the computation part works, but the graphical output doesn't. There should be a dialog displayed. Instead, I only see a tiny window flashed and disappeared. I think this window is for error report of wxPython.

Here is the setup.py I have:

import csv
import numpy as np
import sys
import xlwt
import wx

from AccountClass import Account
from NodeClass import Node
from TreeClass import Tree
from MonteCarloClass import MonteCarloSimulator

# I put down this line to deal with the dll missing problem
sys.path.append('C:\\WINDOWS\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2')

from distutils.core import setup

import py2exe

setup(console = ['main.py'])

May I know why this is happening? Is this because the wxPython doesn't work with py2exe, or I didn't configure them correctly?

ChangeMyName
  • 7,018
  • 14
  • 56
  • 93
  • `wxPython` works just fine with `py2exe`. Can you elaborate on your 'missing dll' problem? I never encountered the need to append an SxS path to the system path in order for bundle an executable using py2exe. My guess is that whatever you were working around with this "fix" is related to the underlying cause for your issue, but I'll need more background to help. – g.d.d.c Feb 21 '14 at 18:48
  • The `dll missing problem` is from this link:http://stackoverflow.com/questions/323424/py2exe-fails-to-generate-an-executable – ChangeMyName Feb 21 '14 at 19:12
  • @g.d.d.c I've tried to `exclude` command in the options, then it turns out that only a `build` folder is created, and no `.exe` file is generated. – ChangeMyName Feb 21 '14 at 19:20
  • @g.d.d.c Please forget my last reply. i've tried the options just as you answered below, and created a `dist` folder which includes `.exe` file. However, again a small window pops up and disappear in a flash. – ChangeMyName Feb 21 '14 at 19:23
  • In that case, more information about what goes on inside your `__name__ == '__main__'` block will be relevant. Are you calling your executable from a command line, or double-clicking on it? Is there a `main.exe.log` file generated in the dist directory? – g.d.d.c Feb 21 '14 at 19:26
  • I double clicked it. In my `main.py`, I have a class, which is the root of the whole application, and I have a `__name__ == '__main__' ` function to create an instance of this class, and trigger the computations. No, there is no `main.exe.log` file generated in the dist folder. – ChangeMyName Feb 21 '14 at 19:29
  • Ok - if you're still calling `setup(console = ...)` then try running your exe from a command prompt and see if it produces any meaningful output. Perhaps there's a traceback it's trying to show you. – g.d.d.c Feb 21 '14 at 19:40

0 Answers0