简体   繁体   English

为什么我的代码在传递给 .exe 时不起作用?

[英]Why my code don't work when I pass it to .exe?

I made a program that detects an image on the screen, I use for it the pyautogui library, when I run my program it works perfectly well, but when I pass it in executable, it does not work anymore and I have the error message below.我制作了一个程序来检测屏幕上的图像,我使用了 pyautogui 库,当我运行我的程序时它工作得很好,但是当我将它传递给可执行文件时,它不再工作了,我有下面的错误消息.

I am under windows 10. I have python 3.10 and pyinstaller 5.0我在 Windows 10 下。我有 python 3.10 和 pyinstaller 5.0

The error message :错误信息:

Traceback (most recent call last):
  File "interface.py", line 21, in <module>
    ScreenLocation = pa.locateOnScreen('module\images\location.PNG', confidence=0.7)
  File "pyautogui\__init__.py", line 175, in wrapper
  File "pyautogui\__init__.py", line 213, in locateOnScreen
  File "pyscreeze\__init__.py", line 373, in locateOnScreen
  File "pyscreeze\__init__.py", line 353, in locate
  File "pyscreeze\__init__.py", line 253, in _locateAll_python
NotImplementedError: The confidence keyword argument is only available if OpenCV is installed.

在此处输入图像描述

I hope I've been clear enough, don't hesitate to ask me questions if there is any information missing to solve my problem, thank you for taking time for me, I hope we will find a solution.我希望我已经足够清楚了,如果缺少任何信息来解决我的问题,请随时向我提问,感谢您抽出时间为我服务,我希望我们能找到解决方案。

Pip 安装 OpenCV 并在脚本中导入 OpenCV。

Its a known issue between OpenCV and Pyinstaller.它是 OpenCV 和 Pyinstaller 之间的一个已知问题。 For now you just need to install previous version of OpenCV 4.5.3.56现在你只需要安装以前版本的 OpenCV 4.5.3.56

 pip install opencv-python==4.5.3.56

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我将可选参数传递给视图时,为什么我的 CSS static 文件不能在 Django 中工作? - Why don't my CSS static files work in Django when I pass an optional parameter to the view? 我的gridsearchCV不起作用,我也不知道为什么 - My gridsearchCV don't work and i don't know why 我不知道为什么我的 'elif' 和 'else' 代码不起作用 - I don't know why my 'elif ' and 'else' code does not work 当我没有为我的 openGLWidget 创建额外的类时,为什么 glRotate 只工作一次? - Why does glRotate work only once when I don't create an extra class for my openGLWidget? 为什么我的 add_pass 函数不起作用? 我是一个新手程序员,所以请不要判断 - Why my add_pass function does not work? I am a newbie programmer so please don't judge 为什么即使我不在 python 中创建海龟对象,我的代码也可以工作 - Why even when I don’t create a turtle object in python my code works 我不明白为什么我的“如果”命令无法正常工作 - i dont understand why my “if” command don't work as it should 为什么附加不起作用,通过引用传递? - Why append don't work, pass by reference? 我不明白为什么我的 python 代码显示警告? - I don't understand why my python code is showing warning? 我不明白为什么我的 for 循环代码有效 - I don't understand why my for loop code works
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM