From 17d20309c7f06baec8a53b3cefd8fda961bfa804 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Mon, 25 Nov 2019 14:17:32 -0800 Subject: [PATCH] leptonica: fix missing Leptonica error message for Windows Since it has the unintuitive fix of adding Tesseract to PATH. --- src/ocrmypdf/leptonica.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/leptonica.py b/src/ocrmypdf/leptonica.py index ca0c546e..6fbf2d99 100644 --- a/src/ocrmypdf/leptonica.py +++ b/src/ocrmypdf/leptonica.py @@ -34,6 +34,7 @@ from os import fspath from tempfile import TemporaryFile from .lib._leptonica import ffi +from .exceptions import MissingDependencyError # pylint: disable=protected-access @@ -43,7 +44,12 @@ if os.name == 'nt': libname = 'liblept-5' else: libname = 'lept' -lept = ffi.dlopen(find_library(libname)) +_libpath = find_library(libname) +if not _libpath and os.name == 'nt': + raise MissingDependencyError( + "Please ensure that 'tesseract' is on your PATH environment variable. " + ) +lept = ffi.dlopen(_libpath) lept.setMsgSeverity(lept.L_SEVERITY_WARNING)