incuna / django-wkhtmltopdf

Django Wrapper to the PDF Renderer: wkhtmltopdf
BSD 2-Clause "Simplified" License
326 stars 155 forks source link

Signals.SIGSEGV: 11 Error with Python 3.9 #180

Open thomasphilibert opened 3 years ago

thomasphilibert commented 3 years ago

Hello guys,

I have just trying to move from python 3.7 to pythhon 3.9 and now, i get an error with django-wkhtmltopdf when i generate a PDF:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/unittest/mock.py", line 1337, in patched
    return func(*newargs, **newkeywargs)
  File "/home/company/code/kit/tests/test_create_kit_form.py", line 533, in test_report_access
    kit_order.completed(post_form.request)
  File "/home/company/code/kit/models.py", line 229, in completed
    self.generate_invoice(request)
  File "/home/company/code/order/models.py", line 40, in generate_invoice
    print(response.rendered_content)
  File "/usr/local/lib/python3.9/site-packages/wkhtmltopdf/views.py", line 73, in rendered_content
    return render_pdf_from_template(
  File "/usr/local/lib/python3.9/site-packages/wkhtmltopdf/utils.py", line 232, in render_pdf_from_template
    return convert_to_pdf(filename=input_file.filename,
  File "/usr/local/lib/python3.9/site-packages/wkhtmltopdf/utils.py", line 165, in convert_to_pdf
    return wkhtmltopdf(pages=pages, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/wkhtmltopdf/utils.py", line 146, in wkhtmltopdf
    return check_output(ck_args, **ck_kwargs)
  File "/usr/local/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['wkhtmltopdf', '--encoding', 'utf8', '--quiet', '/tmp/wkhtmltopdfbb5l238z.html', '-']' died with <Signals.SIGSEGV: 11>.

It seems to come from rendered_content.

I use wkhtmltopdf 0.12.6

All work fine with 3.7

maxpeterson commented 3 years ago

@thomasphilibert from the stack trace it looks like the call to wkhtmltopdf is failing. I am not sure why it would be any different between between Python 3.7 and 3.9.

Since it works with 3.7 we can assume that wkhtmltopdf is working correctly on your system. Is it possible for you to try calling wkhtmltopdf from a Python 3.9 script to see if that works?