import pdfkit from pyvirtualdisplay import Display pdfkit.from_file('report_tmp.html','out.pdf', options={"enable-local-file-access":""})