'No module named error when packing easyocr with pyinstaller

I found an open-source ready-to-use OCR recognition project called easyocr and used it in my own project. I tried to pack my project with pyinstaller, however, only to get an confusing error:

File "easyocr\easyocr.py", line 235, in __init__  
File "easyocr\recognition.py", line 161, in get_recognizer  
File "importlib\__init__.py", line 127, in import_modul 
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import  
File "<frozen importlib._bootstrap>", line 991, in _find_and_load  
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'easyocr.model.model'

Then I tried inlcluding the package's path into pathex, and got another error:

File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
  File "easyocr.py", line 3, in <module>
ImportError: attempted relative import with no known parent package

The rough structure of easyocr is like this:

easyocr/  
    |--> __init__.py  
    |-->easyocr.py  
    |-->recognition.py  
    |-->detection.py
    |--> model/  
        |--> __init__.py  
        |--> model.py

Line 161 in recognition.py is as following:

model_pkg = importlib.import_module("easyocr.model.model")

Line 3 in easyocr.py is as following:

from .detection import get_detector, get_textbox

I've got so confused about these importing issues. Could someone give me some hints to help make it packing my project?
Thanks!



Solution 1:[1]

I finally solved this problem by using --collect-all parameter.

pyinstaller -F project.py --collect-all easyocr

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 genechen