我正在尝试使用tesseract php,但失败了。我得到了这个错误:
Fatal error: Uncaught thiagoalessio\TesseractOCR\TesseractNotFoundException: Error! The command "tesseract" was not found. Make sure you have Tesseract OCR installed on your system: https://github.com/tesseract-ocr/tesseract
The current $PATH is C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Users\Peppe\AppData\Local\Microsoft\WindowsApps;C:\Users\Peppe\AppData\Roaming\Composer\vendor\bin in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php:48 Stack trace: #0
C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\TesseractOCR.php(26): thiagoalessio\TesseractOCR\FriendlyErrors::checkTesseractPresence('tesseract') #1 C:\xampp\htdocs\index.php(7): thiagoalessio\TesseractOCR\TesseractOCR->run() #2 {main} thrown in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 48
我使用的是windows 10,xampp安装在C:\xampp目录下。我从https://github.com/UB-Mannheim/tesseract/wiki安装了tesseract.exe x32和x64,我使用composer安装了https://github.com/thiagoalessio/tesseract-ocr-for-php,它没有给出错误。
<?php
require_once 'C:\Users\Peppe\vendor\autoload.php';
use thiagoalessio\TesseractOCR\TesseractOCR;
$ocr = new TesseractOCR("caption.jpg");
$content = $ocr->run();
echo $content;
?>
最后,caption.jpg位于htdocs文件夹中,也就是出现上述代码的主文件夹和与index.php相同的文件夹中。
有什么解决方案吗?
发布于 2020-10-08 18:25:27
我找到了答案:$PATH变量取自Windows。要将其设置为正确,请搜索“系统环境变量”,单击“环境变量”,编辑路径并添加tesseract软件文件夹,例如C:\Program Files\Tesseract-OCR
https://stackoverflow.com/questions/64199978
复制相似问题