繁体   English   中英

Cx_freeze exe故障排除

[英]Cx_freeze exe troubleshooting

我使用wxpython和boa构造函数编写了一个应用程序。 此应用程序将类实例存储在有序字典中(我导入odict)并最终将数据存储在本地计算机上的搁置中。 应用程序按我的预期运行,所以我想分发它。 以前,我已经使用过pyinstaller但是已经知道python 2.6目前还没有完全支持(由我验证因为我的* exe不起作用)所以我切换到了cx_freeze。 我新编译的exe似乎运行正常,但不会创建搁置文件。 查看构建文件夹中的库文件,我没有看到odict模块。 我看到搁置了。 似乎这是问题,但我不知道为什么不会自动包含odict。 运行应用程序时没有错误,所以我不确定如何找到问题。 任何提示或建议将真诚地感谢。

在Windows XP上使用python 2.6.6,wx python 2.8.11,cx_freeze 4.2.2。

我写了这个例子来尝试确定它是否会编写搁置文件,并且在运行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()

我运行的设置如下,并作为python setup.py构建执行

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]
     )

您始终可以手动包含此类模块

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

注意!! 使用wxpython时需要特别注意。 http://wiki.wxpython.org/cx_freeze

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM