-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
google colab #49
Comments
I ended up using a binder notebook to demo the stuff I was working on. |
the other option is to save the html file locally, open the 'files' sidebar, right click + download and then open it locally. |
The problem is the files for the underlying library vis.js are being linked from the web at the visualization time. This poses a limitation when using the library in environments with no internet connection. It would be great to offer the user an option to specify the location of the required files or, even better, embed the required files into the library. Right know it is possible to patch the template.html file but that should not be the way to go. Is there any licensing reason for not doing so? |
Looks like vis.js is dual licensed, Apache 2.0 and MIT. |
@masdeseiscaracteres do you think that it'd be enough to add a local copy of visjs in the same folder as the html template, and then updating the link? |
I don't think so. That's the first thing I tried and failed miserably. It fails because when you run g.show('example.html') a file called What I did so far was embedding the whole |
BTW, this is how |
that makes sense and prob the way to go. I'm overstretched at the moment but can't wait to have time to hack something together ... |
I finally got it to work. I did two things This has been implemented as part of another library I'm working on (dimcli), but the gist of it is generic enough:
See it in action in this Colab notebook https://drive.google.com/file/d/188vea7vRsLjWvHd0RBnufXOatt43uBcC/view?usp=sharing PS it'd be nice if @boludo00 or one of the maintainers would consider changing pyvis so that Google Colab is supported by default... |
I don't know if something has changed in the last couple of years but it looks like on Colab you just need to perform an extra step to display the generated HTML: from IPython.core.display import display, HTML
g.show('network.html')
display(HTML('network.html')) |
The problem is in the html file that it generates:
It fails with 'vis is not defined' because, as you see, vis library is included with a relative path, which is, obviously, is missing in the notebooks. Not to mention, that it is commented out, lol. The fix would be to include it from cdn, like the rest of js in the file. |
|
works for me |
I got it to work by passing in cdn_resources = 'remote'
|
Possibly helpful to others - as of today, this works with default packages and versions, building on this thread and others. ` from pyvis.network import Network #build graph #populates the nodes and edges data structures |
Hi, great package! I was wondering if you had any tips for getting the graph to load in google colab. Currently, I get 'localhost refused to connect' as an error.
The text was updated successfully, but these errors were encountered: