不能运行pytesseract?

时间:2018-03-12 00:53:39

标签: python python-imaging-library tesseract pillow python-tesseract

我试图在python脚本中使用pytesseract,但是在导入时我一直都会遇到同样的错误。要检查它是来自pytesseract而不是来自其他东西,我直接在我的命令行中键入pytesseract,并收到此错误:

Traceback (most recent call last):
File "/usr/local/bin/pytesseract", line 7, in <module>
from pytesseract.pytesseract import main
File "/Library/Python/2.7/site-packages/pytesseract/__init__.py", line 
1, in <module>
from .pytesseract import (
File "/Library/Python/2.7/site-packages/pytesseract/pytesseract.py", line 9, in <module>
import Image
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 27, in <module>
from . import VERSION, PILLOW_VERSION, _plugins
ValueError: Attempted relative import in non-package

但我知道它已正确安装,因为当我尝试pip install pytesseract --user时,我会回来:

Requirement already satisfied: pytesseract in /Library/Python/2.7/site-packages
Requirement already satisfied: Pillow in /Library/Python/2.7/site-packages (from pytesseract)

我也已经安装了tesseract,我知道因为在命令行中键入tesseract会给我提供所有信息。有谁知道什么是错的?

1 个答案:

答案 0 :(得分:0)

  1. 尝试安装tesseract的依赖软件包并导入Image和Pillow软件包
  2. 或者不是通过pip安装pytesseract,而是从在线https://pypi.org/project/pytesseract/下载pytesseract软件包并安装