【问题标题】:How to import tesseract in python如何在python中导入tesseract
【发布时间】:2019-02-27 16:16:18
【问题描述】:

尝试使用 tesseract python 从图像中提取文本。已安装 tesseract....

tesseract 4.1.0-rc1-21-g8e83  
leptonica-1.77.0   
libjpeg 6b : libpng 1.2.54 : zlib 1.2.8  
Found AVX2  
Found AVX  
Found SSE

但尝试在 python 文件中导入 tesseract 时出现以下错误

导入正方体

ImportError: 没有名为“tesseract”的模块

【问题讨论】:

  • 你安装的tesseract 包看起来像一个二进制而不是python 模块。你是怎么安装的?
  • 尝试了不同的方法.... sudo apt-get install tesseract sudo apt-get install pytesseract
  • 好的,apt-get install tesseract 会将tesseract 二进制文件放入/usr/local/bin,这不能由 Python 导入。如果你这样做pip freeze | grep tesseract,你能看到它安装了吗?
  • 为了清楚起见,您是在 python 虚拟环境中运行它吗?
  • 点冻结 | grep tesseract 给了我... pytesseract==0.2.6 tesseract==0.1.3 tesseract-ocr==0.0.1

标签: python ubuntu tesseract


【解决方案1】:
  • 你安装了tesseract吗?
  • 你安装了 pytesseract 吗?
  • 你在运行什么代码?

这是一个关于如何使用 pytesseract 设置以将 tesseract 与 python 一起使用的教程: https://www.linux.com/blog/using-tesseract-ubuntu

【讨论】:

  • tesseract img.png out 运行良好......即,从命令行......但是来到python脚本,错误如下: Traceback(最近一次调用最后一次):文件“test.py”,第 1 行,在 from pytesseract import image_to_string ImportError: No module named 'pytesseract'
  • 是的...安装了tesseract,pytesseract
  • 实际上试图从下面的链接运行代码.... github.com/artunit/ossocr python ossocr.py -c True -l eng -f page.jpg
  • 如果tesseract安装正确但是python找不到模块,听起来你没有正确安装pytesseract包。它不应该是sudo apt-get install pytesseract,就像您在对该问题的评论中所说的那样,而是sudo pip install pytesseract
  • 也完成了.....要求已经满足:/usr/local/lib/python3.6/dist-packages (0.2.6) 中的 pytesseract 已经满足:/usr/ 中的枕头lib/python3/dist-packages (来自 pytesseract) (3.1.2)
猜你喜欢
  • 2017-02-21
  • 1970-01-01
  • 2013-01-16
  • 2015-10-12
  • 1970-01-01
  • 1970-01-01
  • 2021-04-21
  • 2015-08-16
  • 2021-01-06
相关资源
最近更新 更多