我尝试使用 pytesseract 进行 OCR(从图像中提取文本)。我已经使用命令成功安装了 pytessearct -
pip install pytessearct
当我再次尝试安装时,它清楚地显示 -
Requirement already satisfied (use --upgrade to upgrade):
pytesseract in ./site-packages
这意味着pytessearct安装成功。当我尝试使用 -
在我的 iPython 笔记本中导入这个包时import pytessearct
它抛出一个错误 -
ImportError: No module named pytesseract
为什么会这样?
最佳答案
要使用 Python-tesseract - 需要 python 2.5+ 或 python 3.x - 首先你必须通过 pip 安装 PIL 和 pytesseract 包:
pip install Pillow
pip install pytesseract
然后你必须下载并安装 tesseract OCR:
https://sourceforge.net/projects/tesseract-ocr-alt/?source=typ_redirect
据我所知,它会自动将其添加到您的 PATH 变量中。
然后像这样使用它:
import pytesseract
from PIL import Image
img = Image.open('Capture.PNG')
pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe'
print( pytesseract.image_to_string(img) )
希望对你有帮助:)
关于python - 导入 pytesseract,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38795471/