'_io.BytesIO' object has no attribute 'rfind'

640 Views Asked by At

I'm using fpdf2 to create pdf documents and pygal and cairosvg to render charts on the pdf.

I deployed the app on another machine and I get this error:

'_io.BytesIO' object has no attribute 'rfind'  

Traceback (most recent call last):
File ... in generate_pdf
pdf.image(img_bytesio, x=x, y=y, w=w, h=h)
File "/usr/local/lib/python3.8/dist-packages/fpdf/fpdf.py", line 150, in wrapper
font_size_pt: Optional[int] = None,
File "/usr/local/lib/python3.8/dist-packages/fpdf/fpdf.py", line 963, in image
AttributeError: '_io.BytesIO' object has no attribute 'rfind'

The error points to this section of the code:

svg_img = bar_chart.render()
img_bytesio = BytesIO()
cairosvg.svg2png(svg_img, write_to=img_bytesio, dpi=96)
pdf.add_page()
pdf.image(img_bytesio, x=x, y=y, w=w, h=h)

I've double-checked the versions of the libraries on both machines and they match:

Name: fpdf2
Version: 2.7.3
Name: pygal
Version: 3.0.0
Name: CairoSVG
Version: 2.7.0

Thank you

0

There are 0 best solutions below