ModuleNotFoundError when import witwidget

77 views
Skip to first unread message

xiang yu

unread,
Aug 3, 2021, 8:45:14 AM8/3/21
to What-If Tool
Using WIT in jupyter, after run these command which are all success:
pip install witwidget 
jupyter nbextension install --py --symlink --sys-prefix witwidget 
jupyter nbextension enable --py --sys-prefix witwidget

I run the example code: "WIT_Smile_Detector.ipynb"
I got the following error:
ModuleNotFoundError Traceback (most recent call last) 
<ipython-input-7-2903c022c59c> in <module> 
         1 #@title Invoke What-If Tool for the data and model {display-mode: "form"} 
----> 2 from witwidget.notebook.visualization import WitWidget, WitConfigBuilder 
         3 
         4 num_datapoints = 250 #@param {type: "number"} 
         5 tool_height_in_px = 700 #@param {type: "number"}

what's the reason for that error?   
many thanks in advance.

jwe...@google.com

unread,
Aug 3, 2021, 8:48:48 AM8/3/21
to What-If Tool
Assuming you are using a standard Jupyter notebook setup, and not JupyterLab, then after you run those commands on the command line, you may need to restart your jupyter notebook kernel with the "jupyter notebook" command. Then you should be able to import the modules in the notebook. Ensure there were no errors in any of the installation steps you ran as well. What version of Jupyter are you running?

If you are instead using a JupyterLab setup, then try the instructions at https://github.com/pair-code/what-if-tool#how-do-i-enable-it-for-use-in-a-jupyterlab-or-cloud-ai-platform-notebook.

xiang yu

unread,
Aug 9, 2021, 8:08:28 AM8/9/21
to What-If Tool
I found the root cause, the reason is my pc is behind the company proxy.  After I configed the internal NPM server address (the other way is config the NPM proxy), the problem was solved.
thank you very much!

Reply all
Reply to author
Forward
0 new messages