Python 使用Tesseract时出现符号查找错误

Python 使用Tesseract时出现符号查找错误,python,tesseract,python-tesseract,Python,Tesseract,Python Tesseract,我已经在一个项目中使用Tesseract 4两个多月了。(这意味着它在输入图像上运行了两个多月。)我看到的问题是: multiprocess.pool.RemoteTraceback: """ Traceback (most recent call last): File "/home/cse/.local/lib/python3.5/site-packages/multiprocess/pool.py", line 119, in worker result = (True, fu

我已经在一个项目中使用Tesseract 4两个多月了。(这意味着它在输入图像上运行了两个多月。)我看到的问题是:

multiprocess.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/home/cse/.local/lib/python3.5/site-packages/multiprocess/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/cse/.local/lib/python3.5/site-packages/multiprocess/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/home/cse/.local/lib/python3.5/site-packages/pathos/helpers/mp_helper.py", line 15, in <lambda>
    func = lambda args: f(*args)
  File "UKExtraction2.py", line 267, in tessBox
    op = pt.image_to_string(box[0],lang='hin+eng',config='--psm 6')
  File "/home/cse/.local/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 286, in image_to_string
    return run_and_get_output(image, 'txt', lang, config, nice)
  File "/home/cse/.local/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 194, in run_and_get_output
    run_tesseract(**kwargs)
  File "/home/cse/.local/lib/python3.5/site-packages/pytesseract/pytesseract.py", line 170, in run_tesseract
    raise TesseractError(status_code, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (127, 'tesseract: symbol lookup error: tesseract: undefined symbol: _ZN9tesseract15TessPDFRendererC1EPKcS2_b')
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "UKExtraction2.py", line 855, in <module>
    doItAllUpper("A0","UK4.csv","temp",27,70,"box",2,1000,firstPageCoordsUK,boxCoordUK,voterBoxCoordUK,internalBoxNumberCoordUK,externalBoxNumberCoordUK,addListInfoUK)
  File "UKExtraction2.py", line 776, in doItAllUpper
    doItAll(tempPDFName,outputCSV,2,pdfs,formatType,n_blocks,writeBlockSize,firstPageCoords,boxCoord,voterBoxCoord,internalBoxNumberCoord,externalBoxNumberCoord,addListInfo,pdfName)           
  File "UKExtraction2.py", line 617, in doItAll
    mainProcess(pdfName,(0,noOfPages-1),formatType,n_blocks,outputCSV,writeBlockSize,firstPageCoords,boxCoord,voterBoxCoord,internalBoxNumberCoord,externalBoxNumberCoord,addListInfo,bigPDFName,basePages)
  File "UKExtraction2.py", line 563, in mainProcess
    names_lst = cropAndOCR(im,(tup[0],tup[1]),formatType,boxCoord,voterBoxCoord,externalBoxNumberCoord,n_blocks,basePages)# Add the values of fpageInfo
  File "UKExtraction2.py", line 416, in cropAndOCR
    results = pool.map(tessBox,box_lst_divided)
  File "/home/cse/.local/lib/python3.5/site-packages/pathos/multiprocessing.py", line 137, in map
    return _pool.map(star(f), zip(*args)) # chunksize
  File "/home/cse/.local/lib/python3.5/site-packages/multiprocess/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/home/cse/.local/lib/python3.5/site-packages/multiprocess/pool.py", line 644, in get
    raise self._value
pytesseract.pytesseract.TesseractError: (127, 'tesseract: symbol lookup error: tesseract: undefined symbol: _ZN9tesseract15TessPDFRendererC1EPKcS2_b')
在tesseract ocr google邮件组上发布错误的用户:

combine_tessdata: symbol lookup error: combine_tessdata: undefined symbol: _Z7tprintfPKcz
明白了吗

“未定义符号”表示安装中断

但正如我所说,这个版本已经运行了两个多月,没有任何错误,所以tesseract安装应该不会有任何问题

另一个用户在该组中发布了消息,但没有人回复

因此,我假设问题可能出现在两个地方:

  • 在提供给tesseract的图像中
  • 在tesseract内部 该图像可能不是一个完整的图像!也就是说,它可能有0x0维度(尽管考虑到图像的构造过程,这是不可能的)。但这是不可能的,因为我得到的错误是:

    SystemError: tile cannot extend outside image
    
    当我尝试我的假设时

    这意味着,图像已经存在,因此tesseract应该可以工作

    这也意味着问题在Tesseract内部。我不是tesseract内部工作的专家,但是考虑到这个版本到目前为止工作正常,并且输入图像没有问题,tesseract会有什么问题

    注:我目前不在运行脚本的系统附近,但我知道发生了错误。我可能无法给出关于这个系统的确切细节,因此我希望对这个问题做出假设


    附言:脚本是。

    这是ubuntu 18.04的解决方案

    请首先安装tesseract ocr所需的库

    sudo apt install libtesseract-dev libleptonica-dev liblept5
    
    然后使用命令简单地安装tesseract

    sudo apt install tesseract-ocr -y
    

    作为答案而不是评论发布,以便能够进行修改

    自2019年6月起,Debian GNU/Linux 9.6(stretch)
    (也在9.9上工作)

    当tesseract“突然”停止工作时,我不得不

    sudo apt-get purge libtesseract4 tesseract-ocr
    
    然后再次重新安装(通过后端口,因为稳定通道中不可用):

    在我的例子中,最重要的是重新安装libtesseract4,否则
    符号查找错误:tesseract:undefined symbol
    会一直显示

    sudo apt get安装tesseract ocr

    sudo apt install libtesseract-dev libleptonica-dev liblept5
    

    为我工作

    清除,然后重新安装修复了我的问题:

    sudo apt-get purge libtesseract4 tesseract-ocr
    
    这将删除以下包:

    libtesseract dev*、libtesseract4*、tesseract ocr*

    sudo apt-get install libtesseract-dev tesseract-ocr
    
    这将安装以下软件包:


    libtesseract dev、libtesseract4、tesseract ocr

    该错误是否由特定图像触发?您是否有任何图像在2个月前成功处理,但现在失败了?能否检查
    tesseract--list langs
    是否有错误?谢谢!(在我的情况下,
    sudo-apt-get-install-tesseract-ocr
    sudo apt install libtesseract-dev libleptonica-dev liblept5