**Environment:**

Windows 10

PyInstaller: 5.2

Python: 3.10.5

opencv-python 4.6.0.66


**Problem:**

I am trying to compile my Python code with PyInstaller. The exe is created and when I execute it, I get this error message:

    Traceback (most recent call last):
      File "PhoneBot.py", line 343, in <module>
      File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
      File "modules\prepare_envir_appium.py", line 24, in <module>
      File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
      File "modules\mymodulesteam.py", line 13, in <module>
      File "C:\Users\gauth\AppData\Local\Temp\_MEI40002\cv2\__init__.py", line 181, in <module>
        bootstrap()
      File "C:\Users\gauth\AppData\Local\Temp\_MEI40002\cv2\__init__.py", line 153, in bootstrap
        native_module = importlib.import_module("cv2")
      File "importlib\__init__.py", line 126, in import_module
      File "C:\Users\gauth\AppData\Local\Temp\_MEI40002\cv2\__init__.py", line 181, in <module>
        bootstrap()
      File "C:\Users\gauth\AppData\Local\Temp\_MEI40002\cv2\__init__.py", line 76, in bootstrap         raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')     ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.



**What did I try:**

- I deactivated my Antivirus.
It didn't work

I think I tried it all:

- I installed the previous version of OpenCV:

    pip install opencv-python==4.5.3.56

It didn't work

- I installed the latest version:

    pip install --upgrade opencv-python
    pip install --upgrade pyinstaller

It didn't work

- I tried to force the reinstallation:

    pip3 install opencv-python --upgrade --force-reinstall

It didn't work

- I added the path of cv2:

    pyinstaller --onefile -F --uac-admin --icon="icon_PhoneBot_256.ico" --clean --noconsole  --collect-data pyshadow --paths="C:\Users\gauth\AppData\Local\Programs\Python\Python310\Lib\site-packages\cv2" Project.py

It didn't work

Here are the logs of PyInstaller if it can help:

    130 INFO: PyInstaller: 5.2
    130 INFO: Python: 3.10.5
    268 INFO: Platform: Windows-10-10.0.19044-SP0
    269 INFO: wrote C:\Users\gauth\Documents\project\project_debug3\project.spec
    275 INFO: UPX is not available.
    275 INFO: Removing temporary files and cleaning cache in C:\Users\gauth\AppData\Local\pyinstaller
    353 INFO: Extending PYTHONPATH with paths
    ['C:\\Users\\gauth\\Documents\\project\\project_debug3',
'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\cv2']
    1144 INFO: checking Analysis
    1144 INFO: Building Analysis because Analysis-00.toc is non existent
    1146 INFO: Initializing module dependency graph...
    1152 INFO: Caching module graph hooks...
    1162 WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
    1171 INFO: Analyzing base_library.zip ...
    6500 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.     6502 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib'
    7762 INFO: Caching module dependency graph...
    7923 INFO: running Analysis Analysis-00.toc
    7940 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable       required by C:\Users\gauth\AppData\Local\Programs\Python\Python310\python.exe     8203 INFO: Analyzing C:\Users\gauth\Documents\project\project_debug3\project.py     9270 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.     13260 INFO: Processing pre-find module path hook site from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.     13262 INFO: site: retargeting to fake-dir 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\fake-modules'     22225 INFO: Processing pre-safe import module hook six.moves from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
    32496 INFO: Processing module hooks...
    32501 INFO: Loading module hook 'hook-certifi.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     32518 INFO: Loading module hook 'hook-Cryptodome.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     33041 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34553 INFO: Loading module hook 'hook-cv2.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34568 INFO: Loading module hook 'hook-google.api_core.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34571 INFO: Loading module hook 'hook-googleapiclient.model.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34647 WARNING: collect_data_files - skipping data collection for module 'googleapiclient.discovery' as it is not a package.     34648 INFO: Loading module hook 'hook-httplib2.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34657 INFO: Loading module hook 'hook-lxml.etree.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     34658 INFO: Loading module hook 'hook-lxml.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     35621 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     35622 INFO: Loading module hook 'hook-selenium.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     35985 INFO: Loading module hook 'hook-unidecode.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     37029 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages\\numpy\\_pyinstaller'...
    37120 INFO: Import to be excluded not found: 'f2py'
    37133 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37138 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37139 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37144 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37742 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37749 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37806 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37812 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     37818 INFO: Loading module hook 'hook-pandas.io.formats.style.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...
    39392 WARNING: Hidden import "jinja2" not found!
    39392 INFO: Loading module hook 'hook-pandas.plotting.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     39494 INFO: Loading module hook 'hook-pandas.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     41173 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     41180 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     42001 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     42008 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     42034 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     42044 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     43000 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
    43424 WARNING: Hidden import "pkg_resources.py2_warn" not found!
    43425 WARNING: Hidden import "pkg_resources.markers" not found!
    43431 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     43436 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...
    43663 WARNING: Hidden import "sip" not found!
    43663 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     43837 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     44120 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     44428 INFO: Loading module hook 'hook-pytz.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     44731 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     46244 INFO: Loading module hook 'hook-sqlite3.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     46833 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     46839 INFO: Loading module hook 'hook-win32ctypes.core.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     47606 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     47607 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     47610 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...     47611 INFO: Loading module hook 'hook-_tkinter.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...
    47785 INFO: checking Tree
    47785 INFO: Building Tree because Tree-00.toc is non existent
    47787 INFO: Building Tree Tree-00.toc
    47929 INFO: checking Tree
    47930 INFO: Building Tree because Tree-01.toc is non existent
    47932 INFO: Building Tree Tree-01.toc
    48034 INFO: checking Tree
    48034 INFO: Building Tree because Tree-02.toc is non existent
    48036 INFO: Building Tree Tree-02.toc
    48043 INFO: Loading module hook 'hook-lxml.isoschematron.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     48053 INFO: Loading module hook 'hook-lxml.objectify.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     48054 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     48631 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     49207 INFO: Loading module hook 'hook-win32com.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...     49737 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks'...
    49837 INFO: Looking for ctypes DLLs
    50085 INFO: Analyzing run-time hooks ...
    50106 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'     50113 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'     50120 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32api.py'     50121 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'     50123 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'     50126 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'     50130 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'     50133 INFO: Including run-time hook 'C:\\Users\\gauth\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_subprocess.py'
    50162 INFO: Looking for dynamic libraries
C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\building\build_main.py:156: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
      __import__(package)
    54020 INFO: Looking for eggs
    54021 INFO: Using Python library C:\Users\gauth\AppData\Local\Programs\Python\Python310\python310.dll
    54023 INFO: Found binding redirects:
    []
    54041 INFO: Warnings written to C:\Users\gauth\Documents\project\project_debug3\build\project\warn-project.txt     54297 INFO: Graph cross-reference written to C:\Users\gauth\Documents\project\project_debug3\build\project\xref-project.html
    54366 INFO: Appending 'datas' from .spec
    54373 INFO: checking PYZ
    54373 INFO: Building PYZ because PYZ-00.toc is non existent
    54375 INFO: Building PYZ (ZlibArchive) C:\Users\gauth\Documents\project\project_debug3\build\project\PYZ-00.pyz     56527 INFO: Building PYZ (ZlibArchive) C:\Users\gauth\Documents\project\project_debug3\build\project\PYZ-00.pyz completed successfully.
    56577 INFO: checking PKG
    56578 INFO: Building PKG because PKG-00.toc is non existent
    56580 INFO: Building PKG (CArchive) project.pkg
    86615 INFO: Building PKG (CArchive) project.pkg completed successfully.
    86640 INFO: Bootloader C:\Users\gauth\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
    86640 INFO: checking EXE
    86640 INFO: Building EXE because EXE-00.toc is non existent
    86641 INFO: Building EXE from EXE-00.toc
    86643 INFO: Copying bootloader EXE to C:\Users\gauth\Documents\project\project_debug3\dist\project.exe.notanexecutable
    86648 INFO: Copying icon to EXE
    86653 INFO: Copying icons from ['C:\\Users\\gauth\\Documents\\project\\project_debug3\\icon_project_256.ico']
    86654 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
    86654 INFO: Writing RT_ICON 1 resource with 14739 bytes
    86657 INFO: Copying 0 resources to EXE
    86657 INFO: Embedding manifest in EXE
    86659 INFO: Updating manifest in C:\Users\gauth\Documents\project\project_debug3\dist\project.exe.notanexecutable
    86660 INFO: Updating resource type 24 name 1 language 0
    86663 INFO: Appending PKG archive to EXE
    86763 INFO: Fixing EXE headers
    87437 INFO: Building EXE from EXE-00.toc completed successfully.


Is there anyone who has any idea how to fix this issue?



--


twitter <https://twitter.com/gauthierbuttez>      
        linkedin <https://www.linkedin.com/in/gauthierbuttez/>    

        
        


     GauthierButtez

Centre de Formation France




        0767371715 <tel:0767371715>

[email protected] <mailto:[email protected]>

        https://centredeformationfrance.com 
<https://centredeformationfrance.com>

        14 rue Cantelaudette, Immeuble Pont d'Aquitaine

--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/976ce92a-da86-dd66-1dc1-c8ceebd3f6a4%40CentredeFormationFrance.com.

Reply via email to