sydomain

思绪来的快,去的也快,偶尔在这里停留。

pyinstaller打包exe时报错问题记录

一、简介

最近用pyautogui库写了一个自动化操作的小程序,为了提高识别效率,使用了confidence参数,代码为xy = pyautogui.locateCenterOnScreen(p,grayscale= False,confidence=0.8),其中p为待识别图片参数,confidence:表示灰度值。程序完成后运行没有异常,然后封装时出现一些问题,下面列出两个主要的BUG。


二、报错问题

1. 报出错误【makespec options not valid when a.spec file is given】


因程序中引用多张图片资源

使用指令为

pyi-makespec -F test.py 第一步生成spec文件

pyinstaller -F test.spec 第二步常规打包为exe文件

在运行第二步时就报出makespec options not valid when a.spec file is given错误


解决方法:将-F去掉封装成功


2. 报出错误【NotImplementedError: The confidence keyword argument is only available if OpenCV is install】


封装成功后,运行尝试,想不到闪退,仔细看才发现是报出NotImplementedError: The confidence keyword argument is only available if OpenCV is install,大致意思是“confidence关键字参数仅在OpenCV安装时可用”。


解决办法:将原版本的OpenCV卸载,重新安装OpenCV4.5.3.56解决

安装命令:pip install opencv-python==4.5.3.56


Powered By sydomain

Copyright Your WebSite.Some Rights Reserved.