0

I want to create a PDF from the following Pandas DataFrame:

import pandas as pd
from pybloqs import Block, html
import pybloqs.block.table_formatters as tf

d = {'one': [1., 2., 3., 4.],
 'two': [4., 3., 2., 1.]}

df  =  pd.DataFrame(d)

block_df =  Block(df, formatters=None, use_default_formatters=True)
block_df.save('test.pdf')

and I get the following error (the image is attached): "FileNotFoundError: [WinError 2] The system cannot find the file specified"

According to the documentation, it should work just fine. It seems that in the error it mentions subprocess as well, and I also checked other duplicate questions that point out to subprocess.Popen.

subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)

But that doesn't resolve my problem. Surprisingly, when I run block_df.save('test.html')

it creates a nice HTML file in the same directory. But the error persists for PNG.

enter image description here

mk_sch
  • 1,060
  • 4
  • 16
  • 31

1 Answers1

0

It is failing on "subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)" most liekyl because it cannot find the temporary file. Since you have are asking for PDF, pybloqs will use WkhtmltopdfConverter.

Install wkhtmltopdf (from https://wkhtmltopdf.org/downloads.html) and add the install directory (i.e. C:\Program Files\wkhtmltopdf\bin) to environmental path.

Run wkhtmltopdf in CMD or PowerShell to ensure you have added it to path correctly.

richsykes_
  • 21
  • 4