pyinstaller对多进程程序的打包

在使用python的第三方库pyinstaller对多进程程序进行打包时,程序不能正常的运行,但是后台却有多个进程一直在使用资源。

解决方法很简单,在if __name__ == '__main__':后添加一句代码multiprocessing.freeze_support()就可以了。

if __name__ == '__main__':
    # On Windows calling this function is necessary.
    multiprocessing.freeze_support()

然后在py文件所在目录,调用命令行使用pyinstaller的打包命令pyinstaller -F XXX.py就可以正常打包了,执行结果也能正常显示了。

猜你喜欢

转载自www.cnblogs.com/sjfeng1987/p/9227372.html
今日推荐