模块“notebook”在 vscode 上没有属性“nbextensions”

module 'notebook' has no attribute 'nbextensions' on vscode

提问人:amir g 提问时间:10/25/2023 更新时间:10/25/2023 访问量:141

问:

我在 vscode 上运行 Jupiter,并尝试使用 vpython 运行图形动画。 但是当我运行这个时:

from vpython import graph, canvas
scene = canvas()
g1 = graph(xtitle="x", ytitle="y", width=500, height=250)

我收到错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\Documents\quantum tunneling.ipynb Cell 8 line 2
      1 scene = canvas()
----> 2 g1 = graph(xtitle="x", ytitle="y", width=500, height=250)

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\vpython\vpython.py:2370, in graph.__init__(self, **args)
   2368 def __init__(self, **args):
   2369     objName = 'graph'
-> 2370     super(graph,self).__init__()
   2372 ## default values
   2373     self._width = 640

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\vpython\vpython.py:257, in baseObj.__init__(self, **kwargs)
    254 if not (baseObj._view_constructed or
    255         baseObj._canvas_constructing):
    256     if _isnotebook:
--> 257         from .with_notebook import _
    258     else:
    259         from .no_notebook import _

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\vpython\with_notebook.py:80
     77         transfer = (v != __version__) # need not transfer files to nbextensions if correct version's files already there
     79 if transfer:
---> 80     notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_data",overwrite = True,user = True,verbose = 0)
     81     notebook.nbextensions.install_nbextension(path = package_dir+"/vpython_libraries",overwrite = True,user = True,verbose = 0)
     83     # Wait for files to be transferred to nbextensions:

AttributeError: module 'notebook' has no attribute 'nbextensions'

我尝试重新安装扩展:pip install jupyter_contrib_nbextensions

并启用它:jupyter nbextension enable codefolding/main

我可以在我的 \Python311\site-packages\notebook 路径中看到“nbextensions.py”文件。

所以我不明白为什么它不识别它。

python vpython jupyter-contrib-nbextensions

评论


答: 暂无答案