How to use ipywidgets in jupyter-notebook without Internet

460 Views Asked by At

I have developed interactive application in python using jupyter notebook with ipywidgets and use voila to run the notebook. On my development system (with internet) I have the application working flawlessly. But on the system without internet the application does not load. On inspection with developer tools, the web application is trying to load scripts from mathjax, font-awesome and here

If anyone could guide me on how to workaround this problem ? Run jupyter notebook application with ipywidgets without internet. Can we change some settings / configuration to use the static copy of these dependencies?

---- Update On the system without internet, running jupyter lab and notebook and running the cells works perfectly fine. I am able to view the font-awesome icons and other ipywidgets. This issue is observed only using voila

Thanks in advance for your help.

3

There are 3 best solutions below

0
On

Looks like we need to override the references to cdn and fontawesome in the templates of voila with local references. Please find the reply from Jupyter discourse forum here.

0
On

I had the same issue about "font-awesome" icons which is not working with voila. To workaround it, I'm now using unicode characters in description strings instead of icon property.

0
On

voila still requires some scripts from internet as of March 2023.

I tried to fix it by customizing templates but I was not able to do it for MathJax. I worked it around by replacing internet URLs with local ones with nginx and I am sharing my config as it could be useful to someone else.

  sub_filter_types text/html text/css application/javascript;
  sub_filter 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-MML-AM_CHTML-full,Safe' '/vendor/mathjax-2.7.7-TeX-MML-AM_CHTML-full.Safe.js';
  sub_filter 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS_CHTML-full,Safe' '/vendor/mathjax-2.7.7-TeX-AMS_CHTML-full,Safe.js';
  sub_filter '[MathJax]/extensions/MathMenu.js' '/vendor/MathMenu-2.7.7.js';
  sub_filter '[MathJax]/extensions/MathZoom.js' '/vendor/MathZoom-2.7.7.js';
  sub_filter 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@^5/css/all.min.css' '/vendor/fontawesome.min.css';
  sub_filter 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@^5/css/v4-shims.min.css' '/vendor/fontawesome-v4-shims.min.css';
  sub_filter_once on;