Skip to content
Advertisement

opencv error when converting a python file to an .exe file with pyinstaller

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 "PyInstallerloaderpyimod03_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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement