betatim / notebook-as-pdf

Save Jupyter Notebooks as PDF
BSD 3-Clause "New" or "Revised" License
370 stars 73 forks source link

json version issue? #6

Closed tburnett closed 4 years ago

tburnett commented 4 years ago

Hi, thanks very much for this, it is just what I need for a project I'm developing to use markdown generated from code. It makes very nice notebook output, allowing text and figure captions. What it lacks is a nice way to generate a PDF. However, my first attempt to use if fails with the message from, I guess chromium: nbconvert failed: GET /json/version HTTP/1.1

the version of json, in the latest jupyter, is 2.0.

tburnett commented 4 years ago

I should add that this is on linux, centos7. The command line fails similarly: http.client.BadStatusLine: GET /json/version HTTP/1.1

betatim commented 4 years ago

Hi! Thanks for stopping by :D

How did you resolve this? Posting that might help others who come here and look for answers to similar problems.

tburnett commented 4 years ago

Sorry, pushed wrong button. I'd hoped that it would have meant something to you. I really want to use this, it is exactly what I need.

tburnett commented 4 years ago

It actually hangs up in pyppeteer.launcher.py:166, this line self.browserWSEndpoint = get_ws_endpoint(self.url)

I have no idea what is going on, or why this would generate that error message. So probably nothing to do with your code, I'll try to bring it up with pyppeteer. It may be related to my linux environment, which is a remote server at SLAC.

tburnett commented 4 years ago

Ah, just now, someone else has what seems to be the same pyppeteer issue, https://github.com/pyppeteer/pyppeteer/issues/111. So I'll really close this now.

tburnett commented 4 years ago

This is not an issue here, except that the solution I found requires specifying "--no-sandbox" for the the headless chrome, installed by pyppeteer. In the key functionhtml_to_pdf(html_file, pdf_file) that does all the work, one must insert args=['--no-sandbox'] into browser = await launch(handleSIGINT=False, handleSIGTERM=False, handleSIGHUP=False) The version of chrome that gets installed has several libraries not in Ubuntu, which need to be added via sudo apt-get install. (I maybe should have worried about that sandbox issue, but is completely irrelevant to my application, and I want to get back to science.)