pyvis
pyvis copied to clipboard
html not showing in `vscode` `jupyter` notebook
I have the same issue that is posted by rickhg12hs on the vscode-jupyter page. I'm creating a simple graph via NetworkX, then trying to display it using pyvis. A blank space (of the given height) is the result:
If opened in my browser, the html file works fine:
I had a similar issue when using pyvis on databricks.
The solution for me was to generate raw html and render that. So instead of your show command use:
from IPython.display import HTML
HTML(net.generate_html())
I did try that, unfortunately that also doesn't work. It just creates an empty box and messes up my Jupyter notebook styling:
Try
html = net.generate_html(notebook=True)
HTML(f'<div style="height:{net.height}">{html}</div>', metadata={"isolated": True}, )
I had the same problem, the CSS styling in the generated html is being applied to style the notebook. The isolated
keyword fixes that. I also found that I needed to put the generated html in a div specifying the height of the rendered html, otherwise it rendered with 0 height.
Thank you, but I'm afraid that still doesn't work for me. I get the exact same result as in my reaction to IvoMerchiers above.
Hmm that's strange, it also messes up with the styling of the notebook? Perhaps the isolated keyword only works in jupyter notebooks...
Try
net=Network(notebook=True, cdn_resources='in_line') #specifically cdn_resources
There is a permission bug in chromium based browsers with jupyter notebook where they will not load resources from the local file system. From my observations it's because jupyter has a check on the headers of a request to ensure that who is attempting to grab the file is from jupyter in some way. Though middle of last year chrome started stripping those headers from
cdn_resources
doesn't work for me (or any of the HTML
options.