欢迎光临散文网 会员登陆 & 注册

pyinstaller 打包含有multiprocessing多进程代码异常处理

2023-06-20 14:12 作者:拉灯的小手  | 我要投稿

<table><tr><td bgcolor=orange>本文所有教程及源码、软件仅为技术研究。不涉及计算机信息系统功能的删除、修改、增加、干扰,更不会影响计算机信息系统的正常运行。不得将代码用于非法用途,如侵立删!</td></tr></table>


****

### pyinstaller 打包含有multiprocessing多进程代码异常处理


> `环境`

> - win10

> - python3.9

>- pyinstaller、multiprocessing


### pyinstaller 打包含有多进程代码的程序问题

在windows上Pyinstaller打包多进程程序需要添加特殊指令。

这里是官方github给出的解释:

[https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing](https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing)


修改方式比较简单,在if __name__=='__main__:'下添加一句multiprocessing.freeze_support()即可。


```python

if __name__ == '__main__':

    # pyinstaller 打包含有多进程代码的程序问题,加入下面一行代码,解决

    multiprocessing.freeze_support()

```

![请添加图片描述](https://img-blog.csdnimg.cn/dafe0d6a0efe4dcfb413d83422f3ccd9.jpeg)


****


<table><tr><td bgcolor=orange>本文仅供学习交流使用,如侵立删!wx:1033383881

</td></tr></table>



****


pyinstaller 打包含有multiprocessing多进程代码异常处理的评论 (共 条)

分享到微博请遵守国家法律