【问题标题】:py2exe has inconsistent behavior with its source .py filespy2exe 与其源 .py 文件的行为不一致
【发布时间】:2011-04-07 20:18:31
【问题描述】:

我的 python 程序有很多功能,当从 .py 脚本运行时,它们似乎都可以正常工作。使用 py2exe 编译后,有几段代码的行为非常不一致。

这部分的失败似乎非常一致。

def unzipItem(self, fileName, destination):
    print "--unzipItem--"
    zip = zipfile.ZipFile(fileName)
    nameList = zip.namelist()

    fileCount = 0
    for item in nameList:
        fileCount += 1

    dlg = wx.ProgressDialog("Unziping files",
                           "An informative message",
                           fileCount,
                           parent = self,
                           )

    keepGoing = True
    count = 0

    for item in nameList:
        count += 1
        dir,file = os.path.split(item)
        print "unzip " + file

        self.SetStatusText("Unziping " + str(item))
        (keepGoing, skip) = dlg.Update(count, file)
        zip.extract(item,destination)

    zip.close()
    dlg.Destroy()

ProcessDialog 永远不会出现,SetStatusText 永远不会更新 GUI。

【问题讨论】:

    标签: python py2exe


    【解决方案1】:

    对于为什么会发生这种情况并不是一个真正的答案 - 但使用 cx_Freeze 而不是 py2exe 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 2016-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      相关资源
      最近更新 更多