Python从图片中读取文本,给出一些导入包错误

时间:2019-04-08 20:58:22

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

无法使用PIL和pytesseract从图片中读取文字

import PIL
from PIL import Image
import pytesseract

im = PIL.Image.open('C:\\Users\\Edgar.Lizarraga\\Desktop\\Kaizen-Continuous-Improvement-Model.png')
x = pytesseract.image_to_string(im)
print(x)

给我以下消息:

Traceback (most recent call last):
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Edgar.Lizarraga/PycharmProjects/Pic2/pic2.py", line 3, in <module>
    import pytesseract
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\pytesseract\__init__.py", line 1, in <module>
    from .pytesseract import (
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\pytesseract\pytesseract.py", line 27, in <module>
    from numpy import ndarray
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Users\Edgar.Lizarraga\AppData\Local\Continuum\anaconda33\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified module could not be found.

1 个答案:

答案 0 :(得分:0)

我不确定这是否会导致问题,但是您不需要同时导入PIL和PIL.Image。

将对此发表评论,但我没有50名代表。