简体   繁体   中英

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.

I am under windows 10. I have python 3.10 and 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. For now you just need to install previous version of OpenCV 4.5.3.56

 pip install opencv-python==4.5.3.56

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM