最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - No module named bertviz in jupyter notebook - Stack Overflow

programmeradmin2浏览0评论

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
  • Did you try restarting your kernel? – Adeva1 Commented Mar 19 at 1:15
  • yes, I did. It did not help. – Manfred Kremer Commented Mar 19 at 10:30
  • First, aside from this particular package, you should not be using an exclamation point with pip or conda. 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
  • <continued> The second paragraph here goes into more details about why the exclamation point may lead to issues. For related reasons, you should be also using %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
  • <continued> Second, as to this specific package, %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
Add a comment  | 

1 Answer 1

Reset to default 1

I 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

发布评论

评论列表(0)

  1. 暂无评论