I have a python script running on a remote Ubuntu server. At some point in my code, I create an HTML file which I then convert to a png. I therefore elected to use imgkit, which does the job beautifully well (I tested my code on my Mac OS before uploading the python script to the remote Ubuntu server):
import imgkit
imgkit.from_url('MyFile.html', 'MyFile.png')
Now, the problem is that the Ubuntu server did not have imgkit and wkhtmltopdf installed. So I ran the following command:
sudo pip install imgkit
Then:
sudo apt-get install wkhtmltopdf
Then it returned the error:
QXcbConnection: Could not connect to display
Could not connect to any X display.
You need to install xvfb(sudo apt-get install xvfb, yum install xorg-x11-server-Xvfb, etc),
then add option: {"xvfb": ""}.
So far so good. I therefore ran the following command:
sudo apt-get install xvfb
Which worked. But the Ubuntu server is still returning the same error. Now, for one thing, I have no idea what: then add option: {"xvfb": ""}.
even means. I tried to look for answers online and people quoted that before, without explaining what one should actually do or write in the terminal. I also feel that I am missing extensions for wkhtmltopdf but I am not sure which (again, I ran an online search but I am more confused than anything else at this point. I found similar threads on stack overflow, but nothing quite like the problem I am experiencing). Any help would be deeply appreciated.
Thank you so very much Best regards, Berti