描述现象

用pyinstaller打包了一个上传文件的脚本,里面有多个input在while循环内,然后启用了多线程上传,在编辑器中运行没问题,但是打包完后,就一直循环提示你input...

解决

在google了一段时间后,发现需要在执行入口之前调用

multiprocessing.freeze_support()      # here

然后程序的运行就正常了。

python官网解释

multiprocessing.freeze_support()

Add support for when a program which uses multiprocessing has been frozen to produce a Windows executable. (Has been tested with py2exe, PyInstaller and cx_Freeze.)

One needs to call this function straight after the if name == ‘main‘ line of the main module. For example:

from multiprocessing import Process, freeze_support
def f():
print('hello world!') if __name__ == '__main__':
freeze_support()
Process(target=f).start()
If the freeze_support() line is omitted then trying to run the frozen executable will raise RuntimeError.

Calling freeze_support() has no effect when invoked on any operating system other than Windows. In addition, if the module is being run normally by the Python interpreter on Windows (the program has not been frozen), then freeze_support() has no effect.

pyinstaller打包多线程代码,运行死循环?的更多相关文章

  1. windows使用pyinstaller 打包sklearn模块出现死循环报错

    前言 解决这个让我花费了很长时间, 我这里说的死循环,不是正常通过 --hidden-import能解决的问题. 因为我也查询了很多资料 但是无一例外都失败了(能通过 –hidden-import 解 ...

  2. pyinstaller打包后运行提示“No module named 'PyQt5' "

    记录遇到的一个很傻的问题 脚本用到了PyQt5模块,安装成功脚本可以正常运行,但是使用pyinstaller 打包后,运行 exe文件提示 No module named 'PyQt5' 原因: 因为 ...

  3. win10环境下利用pyinstaller把python代码(.py)打包成可执行文件(.exe)

    前言 最近写了一个小小的检测程序,python写起来只需要短短一百行,可是打包起来就没有C那么容易了.下面记录一下我艰难的"打包"过程. 方法一:py2exe py2exe是一种经 ...

  4. 【终极解决办法】pyinstaller打包exe没有错误,运行exe提示Failed to execute script 'mainlmageWindows' due tounhandled exception: No module named 'docx'

    一.通过pyinstaller打包exe可执行文件,由于我的py是多个,所以要先生成spec文件,代码如下: pyi-makespec mainImageWindows.py 此时生产了一个mainI ...

  5. [python学习笔记] pyinstaller打包pyqt5程序无法运行

    问题 pyinstaller打包的pyqt5程序在部分电脑上会失败.用户截图提示下边错误日志 无法定位程序输入点 ucrtbase.terminate 于动态链接库 api-ms-win-crt-ru ...

  6. pyinstaller 打包生成exe之后运行提示‘no module name 'xxx'’错误

    python 3.7 pyinstaller 3.4 具体情况: pycharm中点击运行可成功执行,生成正确结果,没有报错. 双击run.py(程序运行的主文件),运行,可生成正确结果,没有报错. ...

  7. 解决pyinstaller打包可执行文件,存放路径包含中文无法运行的问题

    一.实验环境 1.Windows7x64_SP1 2.anaconda2.5.0 + python2.7(anaconda集成,不需单独安装) 3.pyinstaller3.0 二.问题描述 1.使用 ...

  8. 【Python】pyinstaller打包运行报错failed to execute script main

    前言 最近用pyinstaller打包的时候一直报"failed to execute script main". 最终使用"pyinstaller --hidden-i ...

  9. pyinstaller打包exe运行失败

    使用Pyinstaller来打包自己开发的软件时遇到的几个问题及解决方法.工具主要功能是数据分析,使用机器学习算法完成数据训练和预测功能.主要用到了两个学习库keras和sklearn,所以说在打包时 ...

  10. pyinstaller打包exe文件,运行时一闪而过

    pyinstaller打包exe文件出现命令窗口一闪而过 原因:exe运行过程中出错了,解决这些错误就可以了 解决方法: 通过 cd path >> xxx.exe 在命令行中运行exe文 ...

随机推荐

  1. Ubuntu18虚拟机远程开发

    Ubuntu18 虚拟机远程开发 1. 安装 VMware 和 Ubuntu18 虚拟机 (1)VMware 官网上下载免费版本 一路 next 安装就行(中间也许需要改一下存放路径) (2)Ubun ...

  2. 五分钟k8s实战-Istio 网关

    在上一期 k8s-服务网格实战-配置 Mesh 中讲解了如何配置集群内的 Mesh 请求,Istio 同样也可以处理集群外部流量,也就是我们常见的网关. 其实和之前讲到的k8s入门到实战-使用Ingr ...

  3. 大语言模型底层架构丨带你认识Transformer

    本文分享自华为云社区<大语言模型底层架构你了解多少?大语言模型底层架构之一Transfomer的介绍和python代码实现>,作者: 码上开花_Lancer . 语言模型目标是建模自然语言 ...

  4. C++ 邮件槽ShellCode跨进程传输

    在计算机安全领域,进程间通信(IPC)一直是一个备受关注的话题.在本文中,我们将探讨如何使用Windows邮件槽(Mailslot)实现ShellCode的跨进程传输.邮件槽提供了一种简单而有效的单向 ...

  5. [ABC279G] At Most 2 Colors

    Problem Statement There is a grid with $1 \times N$ squares, numbered $1,2,\dots,N$ from left to rig ...

  6. springMvc报错

    这个报错困扰了我大概一天,主要是刚开始没抓到主要原因,是因为自己的项目结构出现了问题, 导致找不到应有的东西,另一方面就是maven的问题,将maven解决后这个就能用了. 具体解决在https:// ...

  7. Redis 学习笔记1:数据类型

    Redis支持五种数据类型:string(字符串),hash(哈希),list(列表),set(集合)及 zset(sorted set:有序集合). 一.Redis 数据类型-STRING 1.常用 ...

  8. flask上下文、g变量、current_app

    在flask中的上下文分为两种 : 请求上下文 (request context) 也就是和请求相关的上下文,记录一些请求相关的数据. 包含: 1.request请求对象 2.session会话 应用 ...

  9. storeToRefs()的作用和使用

    store 是一个用 reactive 包装的对象,这意味着不需要在 getters 后面写 .value,就像 setup 中的 props 一样,如果你写了,我们也不能解构它: <scrip ...

  10. Vulkan学习笔记之开发环境搭建

    一.概述 最近因为工作需要开始学习Vulkan的相关知识,作为初学者,发现相对较好的学习资料莫过于vulkan-tutorial,在自己学习Vulkan的过程中,决定将自己的理解记录下来,一是为了加深 ...