在使用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就可以正常打包了,执行结果也能正常显示了。

 

相关文章:

  • 2022-12-23
  • 2021-10-09
  • 2021-12-28
  • 2021-09-03
  • 2022-12-23
  • 2021-12-25
  • 2021-08-29
  • 2022-01-17
猜你喜欢
  • 2022-01-09
  • 2022-02-09
  • 2021-09-11
  • 2021-06-15
  • 2022-02-03
  • 2021-06-07
  • 2022-01-26
相关资源
相似解决方案