我试图在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
会给我提供所有信息。有谁知道什么是错的?
答案 0 :(得分:0)