开发者

Cx_freeze exe troubleshooting

I wrote an application using wxpython and boa constructor. This application stores class instances in ordered dictionaries (I import odict) and ultimately stores the data in a shelve on the local machine. The application runs as I expect, so I want to distribute it. Previously, I have used pyinstaller but have learned that python 2.6 is not fully supported at this time (verified by me because my *exe didn't work) so I switched to cx_freeze. My newly compiled exe seems to run fine, but does not create the shelve file. Looking through the library file in the build folder, I do not see the odict module. I do see shelve. Seems like this is the problem but I don't know why odict is not automatically included. I get no errors when running the application so I'm not really sure how to go about finding the problem. Any tips or suggestions would be sincerely appreciated.

Using python 2.6.6, wx python 2.8.11, cx_freeze 4.2.2 on windows XP.

I wrote this example to try and determine if it would write the shelve file and it doesn't work after running cx_freeze....

import wx
import sys
import os
import shelve

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, 
] = [wx.NewId() for _init_ctrls in range(2)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(557, 369), size=wx.Size(400, 250),
              style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
        self.SetClientSize(wx.Size(392, 223))

        self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='button1',
              name='button1', parent=self, pos=wx.Point(0, 0), size=wx.Size(392,
              223), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME1BUTTON1)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def OnButton1Button(self, event):
        filename='c:\\MakeAShelve.db'
        data=[1,2,3,4]
        database=shelve.open(filename)
        database['data']=data
        database.close()


if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = create(None)
    frame.Show()

    app.MainLoop()

The setup I ran is below and executed as python setup.py build

import sys
from cx_Freeze import setup,Executable


includefiles=[]

exe=Executable(
     script="ShelveTesting.py",
     base="Win32Gui",
     )

setup(
     name="TimingDiagram",
     version="0.2",
     description="An Excel Based Timing Diagram开发者_如何转开发 Application",
     options={'build_exe':{'include_files':includefiles}},
     executables=[exe]
     )


You can always manually include modules like this

build_exe_options = {'packages': ['os','sys','shelve'],'include_files':includefiles}
options = {"build_exe": build_exe_options}

NOTE!! When using wxpython some special care need to be made. http://wiki.wxpython.org/cx_freeze

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜