python用pyinstaller打包后,运行程序报错“pkg_resources.DistributionNotFound“的解决办法...

记录使用supervisor遇到的错误:pkg_resources.DistributionNotFound 背景 基于supervisor+nginx+uWSGI+ flask的一个项目,在docker镜像启动过程中遇到现在的报错问题。其中supervisor的作用在于进程管理,可以对管理的进程进行重启尝试等操作。 在docker镜像制作时,通过apt-get安装了supervisor。 错误代码 pkg_resources.DistributionNotFound: The 'supervisor==3.3.1' distribution was not found and is required by the 阅读详情

错误信息
在这里插入图片描述

  • 删除打包产生的文件:dist文件夹,build文件夹,还有spec文件

先安装pip install pywin32

python用pyinstaller打包后,运行程序报错"pkg_resources.DistributionNotFound"的解决办法…

pkg_resources.DistributionNotFound:the "prettytable" distribution was not found.... 

这里明明已经打包好了exe文件,也没有报错。但是运行exe时候,却弹出这个界面一闪而过。

之后再查阅了pyinstaller的官方文档后,找到了解决办法。

在目标文件目录下创建一个hook-ctypes.macholib.py文件:
里面的内容如下:

# -*- coding: utf-8 -*- 
  
from PyInstaller.utils.hooks import copy_metadata 
  
datas = copy_metadata('prettytable') 
  

这样修改以后,打包出来的exe文件就能够正常使用了。
希望碰到同样的问题的小伙伴,可以从这里找到一些帮助。

refers

Pyinstallerpyinstaller 打包出现几类错误的一般解决方法(不定时更新) 笔者的错误如下: 在用pyinstaller打包(-D 选项),如果用到的第三方库含有data文件,而pyinstaller又没有自带该第三方库文件的hook的时候,执行打包后的exe一般会报以下错误 FileNotFoundError: [Errno 2] No such file or directory: 'd:\\anaconda3\\envs\\tensorflow2\\lib\\site-packages\\pyyaml-5.3.1-py3.6-win-amd64.egg\\EGG-INFO\\ 阅读详情

相关推荐

pyinstaller打包出现pkg_resources.DistributionNotFound: The ‘tzlocal~=2.0‘ distribution was not found

pyinstaller问题记录

lin的博客 650

【错误处理】【pythonpyinstaller打包出错、pkg_resources.DistributionNotFound

error: pkg_resources.DistributionNotFound: The ‘cryptography>=2.1.4’ distribution was not found and is required error: pyinstaller打包时很多dll找不到 解决方案 pip install cryptography pip install lxml pip inst...

mmciel 3841

Pyinstaller打包实战:解决‘pkg_resources.DistributionNotFound‘错误的3种方法(附hook示例)

本文深入解析了使用Pyinstaller打包Python应用时常见的'pkg_resources.DistributionNotFound'错误根源,并提供了三种核心解决方案。重点推荐通过编写自定义hook文件来精确复制缺失的包元数据,这是最规范且一劳永逸的方法。文章还对比了使用`--collect-all`参数和运行时动态修补两种方案的适用场景与优缺点,并附有完整的实战演练流程,帮助开发者彻底解决此类打包难题。

app77的博客 519

pkg_resources.DistributionNotFound 错误

当执行scrapy startproject test时,如果出现:pkg_resources.DistributionNotFound :XXX的错误,则表示缺少XXX 包.如以下错误: (1)pkg_resources.DistributionNotFound : cssselect (2) pkg_resources.DistributionNotFound : queuelib 

ˉ-_lishk_-ˉ 9001

pythonpyinstaller打包有gevent程序遇到的坑,运行程序报错"pkg_resources.DistributionNotFound"解决办法...

具体报错情况如图: 最后一句是重点: pkg_resources.DistributionNotFound:the “cffi>=1.11.5” distribution was not found… 这里明明已经打包好了exe文件,也没有报错。但是运行exe时候,却弹出这个界面一闪而过。 之后再查阅了pyinstaller的官方文档后,找到了解决办法。 创建一个hook-ctypes.m...

weixin_39540280的博客 1万+

pyinstaller打包exe后项目报错pkg_resources.DistributionNotFound

在用pyinstaller打包成功,执行打包后的exe报错

cjl525574193的博客 1010

pyinstaller用包安装后使用时出错pkg_resources.DistributionNotFound: The *** distribution was not

pyinstaller生成可执行文件时报错: C:\Users\骂了隔壁老王\Desktop\MyRestraunt>pyinstaller -F gui_test5.py Traceback (most recent call last): File "C:\python3.7\Scripts\pyinstaller-script.py", line 6, in <module> from pkg_resources import load_entry_point Fil

mlgblw2的博客 1万+

PyInstaller打包报错

我在使用PyInstaller打包文件的时候,命令为Pyinstaller test.py,会弹出下面的报错,-F也有试过,有没有大神能帮忙解答下 pkg_resources.DistributionNotFound: The ‘cryptography’ distribution was not found and is required by the application ...

qq_41698129的博客 2192

pkg_resources.DistributionNotFound: The ‘tzlocal>=1.2‘ distribution was not found and is required by

PyInstaller打包APscheduler出现:pkg_resources.DistributionNotFound: The 'xxx>=yyy' distribution was not found and is required by the application

地理信息系统、摄影测量与遥感、人工智能 1316

PyInstaller打包Sanic记录

报ArgumentError错误,是因为Sanic启动的参数,跟主脚本接受的参数不一致。根本问题是主脚本又执行了一遍。默认打包的过程中,不会带入资源文件。链接:https://www.jianshu.com/p/ff2774387bf3。商业转载请联系作者获得授权,非商业转载请注明出处。作者:_Walker__

ugyguy的博客 421

pkg_resources.DistributionNotFound: The ‘pyqt5_plugins‘ distribution was not found and is required b

pythonQT5项目 打包正常,但是运行的时候报错。The 'pyqt5_plugins' distribution was not found

liuzhang6966的博客 1648

python打包成可执行文件

1 最开始我直接把在Windows上打包的run.exe文件上传到Linux以为可以直接用了。但是./run后报错。百度后知道,Windows上的程序不能在Linux上运行 Linux下文件是否可执行可后缀没有关系,只和权限有关系,靠的是文件本身的权限。想要执行就chmod 755 filename改变文件权限 windows和linux的二进制文件不能兼容,楼主检查下吧,不能在lin...

weixin_30737433的博客 244

Nginx中安装免费SSL证书开启Https请求

在部分场景中,我们必须使用 https 请求,因为 https 请求更为安全,常用于支付方面的请求调用 https 的基础是 ssl,我们一般是没有 ssl 证书的,我们需要向供应商购买 ssl 证书,今天我们使用 Let’s Encrypt 获取免费证书,搭建我们的 https 请求 1、安装 Nginx 在 Centos 中搭建 nginx 环境,可以参考我的这篇文章,Centos7中搭建Nginx环境 https://lizhou.blog.csdn.net/article/details/11604

JACKAL 20万+

bug宝典Pythonpkg_resources.DistributionNotFound: The ‘pip==7.1.0‘ distribution was not found and is

#安装pip tar -zxvf pip-9.0.1.tar.gz cd pip-9.0.1 python setup.py install 再执行pip --version,提示下面的异常[root@ceshi187 pip-9.0.1]# pip --version Traceback (most recent call last): File "/usr/bin/pip", line 5

warrah 南极狼 1万+

pyinstaller打包torch出现OSError: could not get source code、pkg_resources.DistributionNotFound

记下主要怕以后自己忘记 首先打包先建一个虚拟环境,就装上打包python需要的包,这样打包起来错误可能会少点,而且速度也会快些,大小也可能小些,如何创建可以参考我的另一篇博客https://blog.csdn.net/qq_52785473/article/details/122543935?spm=1001.2014.3001.5501 如何导包的时候,也尽量用什么导什么 例如需要用pandas的读文件功能 from pandas import read_csv即可 这样可能对打包的性能也有所提升 打包

学习笔记 6554

pkg_resources.DistributionNotFound:xxx 解决方案之一

最近需要打包python程序所以用到了pyinstaller,然而在安装完各种依赖库打包成功,运行程序的时候出现了缺少bottle库 ,就python.org 上去下载并安装bottle-0.12.13,重新打包运行,提示 pkg_resources.DistributionNotFound:bottle==0.12.13 ,纳闷,已经安装了这个库了。后查看提示信息: file“bottle.py...

zx2017_2_3的博客 2万+

解决 The 'supervisor==3.2.0' distribution was not found and is required by the application错误

ubuntu16.04 修改默认 python 为 anaconda3 后 supervisor.service 报如下错误 Oct 11 09:06:37 zhangyinglong-PC systemd[1]: supervisor.service: Service hold-off time over, scheduling restart. Oct 11 09:06:37 zhangyin...

log003的博客 5895

pkg_resources.DistributionNotFound: The ‘psutil>=5.6.1; platform_python_implementation== 报错解决

今天需要基于gevent来启动gunicorn部署的flask服务,在Python2版本下面的时候是正常启动的,但是在Python3版本下面启动测试的时候就报错了,报错信息如下所示: pkg_resources.DistributionNotFound: The 'psutil>=5.6.1; platform_python_implementation== "CPython"...

Together_CZ的博客 4405
上一篇: Python多线程Threading
下一篇: Python pyinstaller打包pyechart的最佳方法
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值