描述现象

用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. IDEA配置maven引入包时报Unable to import maven project: See logs for details 错误的解决办法

    这也是我遇到的问题,在此记录下一,当时百度了一下午试过了各种方法,最后看到了一位大佬的博客解决了这个问题. 所以我也抄一下大佬博客也是记录一下问题的解决过程,以免下次遇到相似问题再浪费不必要的时间 参 ...

  2. nmap命令说明

    目录 主机发现 扫描技术 端口规格和扫描顺序 服务/版本检测 脚本扫描 操作系统检测 时间和性能: 防火墙/IDS的逃避和欺骗 输出 杂项 平时看到别人的nmap命令都是一大串,根本看不懂为什么,自己 ...

  3. C语言实现输入的时间,屏幕显示一秒后的时间。显示格式为HH:MM:SS。

    #include <stdio.h> int main() { int HH, MM, SS; scanf("%d:%d:%d",&HH,&MM,&am ...

  4. Echarts 柱形图最全详解

    Echarts 是一款基于 JavaScript 的开源可视化图表库,被广泛应用于数据可视化领域.它提供了丰富的图表类型和交互功能,其中柱形图是最常用和重要的一种图表类型之一.下面是对 Echarts ...

  5. 性能测试Mysql之profiling参数

    一.查看profiling状态 mysql> select @@profiling; 0:表示为关闭 1:表示开启 二.开启 profiling mysql> SET profiling= ...

  6. 将 .NET Aspire 部署到 Kubernetes 集群

    使用Aspirate可以将Aspire程序部署到Kubernetes 集群 工具安装 dotnet tool install -g aspirate --prerelease 注意:Aspirate ...

  7. [USACO2007OPENS] Fliptile S

    题目描述 FJ 知道,智商高的奶牛产奶量也大,所以他为奶牛们准备了一个翻动瓦片的益智游戏. 在一个 \(M \times N\) 的方阵上(\(1 \leq M,N \leq 15\)),每个格子都有 ...

  8. [USACO2007NOVG] Cow Relays G

    题目描述 For their physical fitness program, N (2 ≤ N ≤ 1,000,000) cows have decided to run a relay race ...

  9. C++学习笔记九:值,常量,常表达式和常初始化

    1. 值: Literal: Data that is directly represented in code without going through some other variable s ...

  10. 一招MAX降低10倍,现在它是我的了

    一.背景 性能优化是一场永无止境的旅程. 到家门店系统,作为到家核心基础服务之一,门店C端接口有着调用量高,性能要求高的特点. C端服务经过演进,核心接口先查询本地缓存,如果本地缓存没有命中,再查询R ...