Reputation: 13
So I am trying to convert my python project to an exe file and run it, but when I do, I get an error like this:
Failed to execute script 'My project' due to unhandled exception: ERROR recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
Traceback (most recent call last):
File "Myproject.py", line 3, in module
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "cv2\__init__.py", line 180, in module
File "cv2\__init__.py", line 75, in bootstrap
ImportError:
ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
Here's some of the code:
import pyautogui as pg
from time import sleep
import cv2
sleep(1)
pg.hotkey('super', 's')
sleep(0.2)
pg.typewrite('chrome')
sleep(0.3)
pg.press('enter')
sleep(0.4)
pg.typewrite('youtube.com')
pg.press('enter')
sleep(1)
cords = pg.locateCenterOnScreen('search.png', confidence=0.8)
pg.click(cords)
pg.typewrite('a random video')
pg.press('enter')
any help would be appreciated.
Upvotes: 0
Views: 2424
Reputation: 1
I also got the same error. I got around the error by lowering the python and opencv versions. I used following versions :
Python 3.9.13
opencv-python==4.5.3.56
I've tried several combinations, but there seems to be no error.
Upvotes: 0
Reputation: 13
Just found out the problem.I was using the latest 3.10.0 version of Python and apparently, it had some bugs about numpy and opencv modules.
My Advice:
Never use the latest python version. Always the previous one.
Upvotes: 1
Reputation: 89
Try uninstalling opencv and installing an older version, like version 4.5.3
Upvotes: 1