使用 tesserocr 遇到 ImportError:在平面命名空间 '__ZN9tesseract11TessBaseAPID1Ev' 中找不到符号

Jim*_*han 4 python macos tesseract importerror

我试图在我的 Python 项目中使用 tesserocr,但是当我尝试导入它时,我遇到[No module named 'tesserocr']了 ImportError。该错误消息指出缺少与 Tesseract 库相关的符号。这是完整的错误消息:

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'
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止所做的:

  1. 使用brew安装了tesseract:brew install tesseract

  2. 在虚拟环境中通过 pip 安装 tesserocr:pip install tesserocr

  3. 确认 tesseract 命令行正常工作。我在 macOS M1 上运行它,我的 Python 版本是 3.8。

如何解决此问题以便我可以在我的项目中使用 tesserocr?是否有我可能缺少的特定路径或配置?

任何有关可能导致此错误的原因的帮助或指示将不胜感激!

Jim*_*han 5

我在尝试使用该tesserocr软件包时遇到了问题,但我设法找到了解决方案,并希望将其分享给可能遇到相同问题的任何人。

通过首先完全卸载 tesserocr 软件包,然后使用--no-binarypip 选项重新安装它,解决了该错误。以下是我使用的命令:

  1. 卸载tesserocr:pip uninstall tesserocr
  2. 不使用二进制包重新安装 tesserocr:pip install --no-binary :all: tesserocr

执行完这两个步骤后,错误消失了,tesserocr 可以按预期工作。

我希望这可以帮助遇到同样问题的人!