我有一大堆 PDF,无法进行 OCR,因为每个 PDF 都有一小部分可渲染文本。
我正在尝试将它们全部转换为 TIFF,以便我可以转换回来并运行 OCR,但我在调用我希望完成这项工作的程序时遇到了问题。我安装它们没有问题,但由于某种原因,我不断收到错误,说相关命令不存在:
c:\Program Files\Python37\Lib\site-packages>pip install tesseract
Requirement already satisfied: tesseract in c:\program files\python37\lib\site-packages (0.1.3)
c:\Program Files\Python37\Lib\site-packages>tesseract --version
'tesseract' is not recognized as an internal or external command,
operable program or batch file.
c:\Program Files\Python37\Lib\site-packages>pip install ghostscript
Requirement already satisfied: ghostscript in c:\program files\python37\lib\site-packages (0.6)
Requirement already satisfied: setuptools in c:\program files\python37\lib\site-packages (from ghostscript) (40.8.0)
c:\Program Files\Python37\Lib\site-packages>gs --version
'gs' is not recognized as an internal or external command,
operable program or batch file.
c:\Program Files\Python37\Lib\site-packages>gswin32c --version
'gswin32c' is not recognized as an internal or external command,
operable program or batch file.
有什么想法我做错了吗?
如果您有更好的方法来执行整体任务,即可获得奖励积分。
我注意到您使用的是 Windows,我猜测您尚未将 Ghostscript 安装目录添加到 $PATH 环境变量中,因此 Windows 不知道在哪里查找可执行文件。
Python 可能可以使用 python37\lib\site-packages 目录中的 Ghostscript 可执行文件,但 Windows 不会知道这一点,除非被告知去那里查看。它可能是一个子目录,除非 Python 包安装程序使用普通 Ghostscript Windows 安装程序之外的其他内容。
请注意,在 Windows 上,二进制文件不称为“gs”;它将是 gswin32、gswin64、gswin32c 或 gswin64c,具体取决于您安装的是 32 位还是 64 位版本的 Ghostscript,以及您需要命令行 (c) 还是窗口版本。
找到它的最简单方法可能是查看指定的 Python 文件夹并查看。