Jupyter Notebook扩展加载错误。

29

我正在使用搭载OS Sierra的Macbook,运行Python 3.6.1和Jupyter Notebook Server 5.0.0。根据https://github.com/ipython-contrib/jupyter_contrib_nbextensions上的说明,我安装了Jupyter Notebook扩展。

尽管笔记本在我的系统上工作正常,但是我无法查看nbextensions选项卡。运行终端中的jupyter notebook后,我看到以下错误日志。我在这里看到了一些相关问题的帖子,但它们似乎都是关于安装特定扩展的。

此外,其中一个解决方案似乎提出了pip install jupyter_nbextensions_configurator,但是如下面的输出所示,我已经安装了该扩展名。

Requirement already satisfied: traitlets in /usr/local/lib/python3.6/site-packages (from jupyter_nbextensions_configurator)
Requirement already satisfied: tornado in /usr/local/lib/python3.6/site-packages (from jupyter_nbextensions_configurator)

然而,在日志中,您会注意到ModuleNotFoundError: No module named 'jupyter_nbextensions_configurator'是其中一个错误信息。

[W 08:44:49.973 NotebookApp] server_extensions is deprecated, use nbserver_extensions
[W 08:44:50.146 NotebookApp] Error loading server extension jupyter_nbextensions_configurator
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1271, in init_server_extensions
        mod = importlib.import_module(modulename)
      File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 978, in _gcd_import
      File "<frozen importlib._bootstrap>", line 961, in _find_and_load
      File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'jupyter_nbextensions_configurator'
[I 08:44:50.158 NotebookApp] Serving notebooks from local directory: /Users/sp
[I 08:44:50.158 NotebookApp] 0 active kernels
[I 08:44:50.158 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=c777a7ab5dc6cf416c238b7b37f58d10ebea9db0743b46ae
[I 08:44:50.158 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:44:50.163 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://localhost:8888/?token=c777a7ab5dc6cf416c238b7b37f58d10ebea9db0743b46ae
[I 08:44:51.633 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[W 08:44:54.407 NotebookApp] 404 GET /nbextensions/nbextensions_configurator/tree_tab/main.js?v=20170511084449 (::1) 25.76ms referer=http://localhost:8888/tree

我在这里缺少什么?谢谢!

7个回答

28

我也遇到了同样的问题,以下是我解决的方法。

我下载了Anaconda Python 3.7版本。我已经在我的系统上安装了Python 3.6.7。

如果我执行以下操作,就会出现这个错误:

pip install jupyter_contrib_nbextensions
为了解决它,我做了以下事情:
python3.7 -m pip install jupyter_contrib_nbextensions

我没有尝试过这个方法,但是它可能也能解决你的问题:

conda install -c conda-forge jupyter_nbextensions_configurator

我猜问题是由于您的系统上存在多个Python版本所致。Anaconda使用的版本和"普通pip"使用的版本可能不同。


2
Python 应默认使用环境中的 Python:python -m pip install jupyter_contrib_nbextensions 应该可以工作。 - Cam Cairns
2
就我的问题而言,我在虚拟环境和全局环境中都安装了Jupyter。默认情况下,“jupyter”命令会选择全局环境。因此,我通过从虚拟环境运行Jupyter二进制文件(./<venv>/bin/jupyter)来解决了我的问题。 - Aneesh Makala

12

我通过移除jupyter-notebook、jupyter_contrib_nbextensions和jupyter_nbextensions_configurator并从头开始启动来解决了这个问题。

注意:它只适用于Anaconda环境。

卸载

对于不同安装源,您可以通过以下方式删除这些软件包:

pip uninstall jupyter
pip uninstall jupyter_contrib_nbextensions
pip uninstall jupyter_nbextensions_configurator
或者
conda remove --force jupyter notebook
conda remove --force jupyter_nbextensions_configurator
conda remove --force jupyter_contrib_nbextensions

但是我建议您运行上述两个命令.

安装

最好从Anaconda安装所有软件包:

conda update notebook
conda install jupyter notebook
conda install -c conda-forge jupyter_nbextensions_configurator
conda install -c conda-forge jupyter_contrib_nbextensions


2
我们中的一些人无法使用Conda。需要找到一种解决方案,以满足所有Jupyter笔记本用户的需求。 - MyopicVisage
@MyopicVisage 我已经在答案中添加了一条注释。感谢您的建议! - Xiong-Hui Chen
@MyopicVisage...上述解决方案实际上并没有使用"Anaconda",而是使用了开源软件包conda。为什么您不能使用conda呢?您是否处于受限制的IT环境中? - Rich Lysakowski PhD
我同时使用了conda和jupyter。这帮助我恢复了之前的状态。谢谢! - Sachin

1

我曾经也遇到同样的问题,但是在jupyterlab的README中我注意到了以下内容:

先决条件

Jupyter notebook版本4.3或更高。检查笔记本版本的方法如下:

jupyter notebook --version

因此,请使用该命令检查您的版本,如果返回的版本低于4.3,请尝试更新它:

conda update notebook

这就是我解决问题的方法。


0

我刚刚也遇到了同样的问题,但是我通过更改特定的环境(例如tensorflow或py36),然后输入“jupyter notebook”成功解决了它。


0
从服务器回溯来看,似乎你可能有多个Python安装时出现了一些奇怪的情况。请注意,你正在安装到一个Python中。
/usr/local/lib/python3.6

但你的笔记本服务器回溯从那里开始(似乎是notebookapp正在运行的地方),但是在导入调用中越过,从安装在(homebrew?)的Python 上运行

/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6

一个可能有点hackish的解决方案是直接安装到那个cellar中,然后像以前一样继续进行,但我建议进行更多的调查来确定为什么会发生这种情况。与此相关的可能是您如何启动笔记本服务器、安装模块、运行终端、设置Python路径等等...

0
我通过在Anaconda中切换到基本环境并安装这些软件包来解决了我的问题。一开始,由于某些conda-forge软件包无法安装,我在Anaconda中创建了一个新的环境,并在该环境中使用了'pip install'。我安装了这些软件包,但选项卡没有显示出来。原因是即使我激活了新环境,jupyter notebook仍然在基本环境中初始化。这就是为什么jupyter nootbook在一开始会显示 'no module found' 的原因。

-1
我长时间遇到了同样的错误。重新安装nbconfig,更改设置,给它额外的加载时间,在打开笔记本之前验证安装等都没有帮助。
最终对我有用的是切换浏览器!我从我的Mac上的Safari切换到Chrome,一切都工作得很完美!(Safari版本13.0.2,mac OS High Sierra 10.13.6,Chrome版本83.0.4103.61)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接