问题遇到的现象和发生背景
问题:在Python上多次尝试安装tesserocr出现报错
背景:已安装完成tesseract,pillow,wheel,但没确定过版本,在cmd下可以查询到tesseract,已设置好tesseract.exe和tessdate的系统环境下的路径.
问题相关代码
在尝试最终pip install tesserocr时报错
运行结果及报错内容
Collecting tesserocr
Using cached tesserocr-2.5.2.tar.gz (57 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [44 lines of output]
Failed to extract tesseract version number from: tesseract v5.2.0.20220712
leptonica-1.78.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found FMA
Found SSE4.1
Found libarchive 3.5.0 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5 libzstd/1.4.5
Found libcurl/7.77.0-DEV Schannel zlib/1.2.11 zstd/1.4.5 libidn2/2.0.4 nghttp2/1.31.0
Supporting tesseract v3.04.00
Tesseract major version 3
Traceback (most recent call last):
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 243, in get_build_args
build_args = package_config()
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 99, in package_config
p = subprocess.Popen(
File "C:\Users\mao'xi'zhou\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\mao'xi'zhou\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 327, in <module>
ext_modules=[make_extension()],
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 260, in make_extension
build_args = get_build_args()
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 252, in get_build_args
build_args = get_tesseract_version()
File "C:\Users\mao'xi'zhou\AppData\Local\Temp\pip-install-zeb2ridn\tesserocr_a7c4cf0874344db0a6dd2df338154578\setup.py", line 216, in get_tesseract_version
raise RuntimeError(error)
RuntimeError: Tesseract library not found in LIBPATH: []
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
我的解答思路和尝试过的方法
网上都搜索过尝试过解决办法,但没有找到与自己相适应的。
我成功下载了pytesseract模块,但却给予图片没有给出识别的内容。
>>>image2
<PIL.Image.Image image mode=L size=160x60 at 0x1436019AF40>
>>>s=pt.image_to_string(image2)
>>>s
''