I installed
!pip install bertviz
in the jupyter notebook. With
!conda list bertviz
I also get the information that bertviz version 1.4.0 is installed.
After
from bertviz import head_view, model_view
I get an error message "No module named 'bertviz'". I have restarted the notebook, but it does not help. So I ask for your help.
I hope I have formatted this right, there is no preview function.
I installed
!pip install bertviz
in the jupyter notebook. With
!conda list bertviz
I also get the information that bertviz version 1.4.0 is installed.
After
from bertviz import head_view, model_view
I get an error message "No module named 'bertviz'". I have restarted the notebook, but it does not help. So I ask for your help.
I hope I have formatted this right, there is no preview function.
Share Improve this question edited Mar 19 at 10:27 Adeva1 4941 silver badge8 bronze badges asked Mar 18 at 22:59 Manfred KremerManfred Kremer 214 bronze badges 5 |1 Answer
Reset to default 1I think the issue is Jupyter was installed globally. It defaults to the system's Python environment. So your virtual environment was not detected automatically and it doesn't automatically recognize packages installed in your virtual environment. Your virtual environment has its own isolated Python interpreter with its own installed packages.
Easiest fix is go to menu Kernel-Change Kernel and choose your active virtual environment
pip
orconda
. The magic pip command variation was added in 2019 to ensure the install occurs in the environment where the kernel is running that backs the active notebook. The exclamation point doesn't do that and can lead to issues. See more about the modern%pip install
command here. ... – Wayne Commented Mar 20 at 16:16%pip list
or%conda list
to see what is installed in the kernel environment that your notebook is using. Even in Google Colab, it should now be%pip install
to keep consistent with the rest of the Jupyter universe, despite what the outdated information there says. – Wayne Commented Mar 20 at 16:17%pip install bertviz
should work and I can share a way to demonstrate because having a place where it works may allow you to compare and contrast. Go to here to where one of the Jupyter developers offers a current version of Jupyter and click the 'launch binder
' badge. You'll get a temporary Jupyter session on a remote computer without needing to login or touch your own system. When the session comes up open a new notebook and paste in%pip install bertviz
and run it. – Wayne Commented Mar 20 at 16:25