Search code examples
pythonmacostesseractimporterror

Encountering ImportError with tesserocr: Symbol not found in flat namespace '__ZN9tesseract11TessBaseAPID1Ev'


I'm attempting to use tesserocr in my Python project, but when I try to import it, I'm getting [No module named 'tesserocr'], I run into an ImportError. The error message points to a missing symbol related to the Tesseract library. Here is the full error message:

ImportError: dlopen(/Volumes/WorkSpace/Backend/Reveratest/revera_api/venv/lib/python3.8/site-packages/tesserocr.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '__ZN9tesseract11TessBaseAPID1Ev'

Here's what I've done so far:

  1. Installed tesseract using brew: brew install tesseract

  2. Installed tesserocr via pip within a virtual environment: pip install tesserocr

  3. Confirmed that tesseract command-line works correctly. I'm running this on macOS M1 and my Python version is 3.8.

How can I resolve this issue so that I can use tesserocr in my project? Are there specific paths or configurations I'm possibly missing?

Any assistance or pointers as to what might be causing this error would be greatly appreciated!


Solution

  • I ran into a problem when trying to work with the tesserocr package, but I managed to find a fix and wanted to share it for anyone who might be experiencing the same issue.

    The error was resolved by first completely uninstalling the tesserocr package and then reinstalling it using the --no-binary option with pip. Here are the commands I used:

    1. Uninstall tesserocr: pip uninstall tesserocr
    2. Reinstall tesserocr without using binary packages: pip install --no-binary :all: tesserocr

    After performing these two steps, the error was gone, and tesserocr was working as expected.

    I hope this helps someone who faces the same problem!