Search code examples
pythontesseractpyinstallerpython-tesseract

Trouble using PyInstaller in Ubuntu


I have a python application where I'm using tesserocr, ocrmypdf. I am trying to create a stand-alone executable of it by using PyInstaller.

I can successfully create the executable by using the following command

$ pyinstaller -F --clean code.py

But when I run it

$ ./code

I get this error

ModuleNotFoundError: No module named 'tesserocr'

ModuleNotFoundError: No module named 'ocrmypdf'

code.py

from tesserocr import PyTessBaseAPI
import ocrmypdf

...

I have cross checked tesserocr and ocrmypdf are successfully installed in my system.


Solution

  • Try this

    pyinstaller -F --clean code.py --hidden-import='tesserocr.PyTessBaseAPI' --hidden-import='ocrmypdf'