From 229ad9ff4a3dc3814d2b863990b4efdc5dd8540e Mon Sep 17 00:00:00 2001 From: CNOCTAVE Date: Sat, 24 May 2025 11:00:17 +0800 Subject: [PATCH] Fix #269 Fix #269 --- pdfkit/configuration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pdfkit/configuration.py b/pdfkit/configuration.py index 11785e1..06837d5 100644 --- a/pdfkit/configuration.py +++ b/pdfkit/configuration.py @@ -25,6 +25,15 @@ def __init__(self, wkhtmltopdf='', meta_tag_prefix='pdfkit-', environ=''): self.wkhtmltopdf = subprocess.Popen( ['where.exe', 'wkhtmltopdf'], stdout=subprocess.PIPE, startupinfo=startupinfo).communicate()[0] else: + try: + subprocess.Popen( + ['which'], stdout=subprocess.PIPE).communicate()[0] + except (IOError, FileNotFoundError) as e: + raise IOError('No which executable found. ' + 'If this file exists please check that this process can ' + 'read it or you can pass path to it manually in method call, ' + 'check README. Otherwise please install which - ' + 'https://github.com/JazzCore/python-pdfkit/wiki/Installing-which') self.wkhtmltopdf = subprocess.Popen( ['which', 'wkhtmltopdf'], stdout=subprocess.PIPE).communicate()[0]