'OCRmyPDF throws [WinError 2] The system cannot find the file specified

I've got a strange error: as soon as I run OCRmyPDF (inside Python or cmd), my output is stuffed with the following error message: [WinError 2] The system cannot find the file specified

Even through the "verbosity=True" option in the logger, I get no indication of the origin of the error message (I get this error already when I only import the library). Also, the function does exactly what it is supposed to do and the process completes with exit code 0.

Does anybody know, what could be wrong there?

Best, Kevin



Solution 1:[1]

Please follow the following two steps

  1. Install camelot-py from https://pypi.org/project/camelot-py/.

  2. Then after install Ghostscript from https://www.ghostscript.com/download/gsdnld.html and add in environment variables.

NOTE: Add the following path in computer environment variables

C:\Program Files\gs\gs9.54.0\bin

C:\Program Files\gs\gs9.54.0\lib

Then after restart your computer, then problem fixed.

NOTE: But if you still face an error, make sure you have install ocrmypdf version 12.2.o by command. pip install ocrmypdf==12.2.0

Thank you

Solution 2:[2]

The OCRMyPDF library depends heavily on some packages that are not available on windows by default. Tesseract (https://tesseract-ocr.github.io/tessdoc/), GhostScript (https://www.ghostscript.com/) and Unpaper for instance. You need to ensure they are installed and available in your path. Using a package manager like chocolatey can make getting these packages installed a straightforward process.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2