Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pyinstaller-exe执行Python脚本以外的其他操作_Python_Multithreading_Wxpython_Pyinstaller - Fatal编程技术网

Pyinstaller-exe执行Python脚本以外的其他操作

Pyinstaller-exe执行Python脚本以外的其他操作,python,multithreading,wxpython,pyinstaller,Python,Multithreading,Wxpython,Pyinstaller,我的pyinstaller和程序有问题。如果我启动脚本,一切都正常运行,但是如果我运行exe,它会做一些奇怪的事情 这段代码应该在显示一个框架时做些什么,如果它完成了,框架应该被破坏。但是在exe中它不会创建任何东西,但是在一段时间后创建第二个主框架(在这个脚本中没有创建主框架,这只发生在wxpython应用程序中)。 以下是创建框架的代码: # self is a wx.Frame def handleInputs(self): path = self.setSavePath() #

我的pyinstaller和程序有问题。如果我启动脚本,一切都正常运行,但是如果我运行exe,它会做一些奇怪的事情

这段代码应该在显示一个框架时做些什么,如果它完成了,框架应该被破坏。但是在exe中它不会创建任何东西,但是在一段时间后创建第二个主框架(在这个脚本中没有创建主框架,这只发生在wxpython应用程序中)。 以下是创建框架的代码:

# self is a wx.Frame
def handleInputs(self):
    path = self.setSavePath() # setSavePath just takes a path from a fileDialog
    if path:
        self.dialog = WaitingDialog() # subclass of wx.MiniFrame
        self.dialog.Show(True)
        calcThread = threading.Thread(target=self.doStuff)
        checkThread = threading.Thread(target=self.checkFinishing)
        calcThread.start()
        checkThread.start()
        self.Disable()

def checkFinishing(self, thread):
    while thread.is_alive():
        pass
    wx.CallAfter(self.closeFrame)
    return True

def doStuff(self):
    # do Stuff here
    return True

def closeFrame(self):
    self.dialog.Destroy()
    self.Destroy()
因此,调用了self.handleInputs(),但在应用程序中,doStuff()中似乎什么都没有做,然后创建了一个新的主框架。
您是否看到任何错误或知道发生这种情况的原因

现在解决了它,删除了多处理的所有用途

有关如何使用pyinstaller的信息将有所帮助,演示该问题的SSSCE()也会有所帮助。目前,我无法使用您提供的内容重现您的行为。此外,您是否在应用程序的任何位置使用多处理功能?如果uuu name uuu=='\uuuuuu main uuu'块的缩进不正确,那么应该在
下的内容是否可能存在?PyInstaller的两次执行可能会产生奇怪的行为。谢谢,现在已经解决了,问题是多处理。我现在删除了所有进程并使用线程,但现在速度慢了一点。对不起,如果我的例子有点不具体,那就太晚了:(我将在下次找到此解决方案时记住这一点:,但它比使用线程慢得多。我个人认为使用py2exe比使用pyinstaller更幸运。pyinstaller中的两次执行会降低性能,特别是对于小型、快速运行的脚本。