繁体   English   中英

nglview 已安装但不会通过 Anaconda.Navigator 导入到 Juypter Notebook 中

[英]nglview installed but will not import inside Juypter Notebook via Anaconda.Navigator

我在 Juypter Notebook (JNb) 单元格中导入 nglview 时遇到问题。 JNb 的实例是通过 Anaconda.Navigator GUI 中的基础(根)环境启动的。 在 Anaconda.Navigator 中,我安装了 nglview。 但是导入仍然失败。

版本:

  • Jupyter Notebook(在 Anaconda.Navigator 内)- 6.4.12
  • Anaconda.Navigator (GUI) - 2.3.2
  • Python - 3.9
  • nglview - 3.0.3(已安装但未导入)
  • ipython 8.5.0

这是错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In [1], line 5
      3 import pandas as pd
      4 import matplotlib.pyplot as plt
----> 5 import nglview as nv
      7 # the next line is necessary to display plots in Jupyter
      8 get_ipython().run_line_magic('matplotlib', 'inline')

File ~\anaconda3\lib\site-packages\nglview\__init__.py:4
      1 import warnings
      3 # for doc
----> 4 from . import adaptor, datafiles, show, widget
      5 from ._version import get_versions
      6 from .adaptor import *

File ~\anaconda3\lib\site-packages\nglview\show.py:13
      3 from . import datafiles
      4 from .adaptor import (ASEStructure, ASETrajectory, BiopythonStructure,
      5                       FileStructure, HTMDTrajectory, IODataStructure,
      6                       IOTBXStructure, MDAnalysisTrajectory, MDTrajTrajectory,
   (...)
     11                       RdkitStructure,
     12                       TextStructure)
---> 13 from .widget import NGLWidget
     15 __all__ = [
     16     'demo',
     17     'show_pdbid',
   (...)
     40     'show_biopython',
     41 ]
     44 def show_pdbid(pdbid, **kwargs):

File ~\anaconda3\lib\site-packages\nglview\widget.py:19
     15 from traitlets import (Bool, CaselessStrEnum, Dict, Instance, Int, Integer,
     16                        List, Unicode, observe, validate)
     17 import traitlets
---> 19 from . import color, interpolate
     20 from .adaptor import Structure, Trajectory
     21 from .component import ComponentViewer

File ~\anaconda3\lib\site-packages\nglview\color.py:114
    110         else:
    111             raise ValueError(f"{obj} must be either list of list or string")
--> 114 ColormakerRegistry = _ColormakerRegistry()

File ~\anaconda3\lib\site-packages\nglview\base.py:10, in _singleton.<locals>.getinstance()
      8 def getinstance():
      9     if cls not in instances:
---> 10         instances[cls] = cls()
     11     return instances[cls]

File ~\anaconda3\lib\site-packages\nglview\color.py:47, in _ColormakerRegistry.__init__(self, *args, **kwargs)
     45 try:
     46     get_ipython() # only display in notebook
---> 47     self._ipython_display_()
     48 except NameError:
     49     pass

File ~\anaconda3\lib\site-packages\nglview\color.py:54, in _ColormakerRegistry._ipython_display_(self, **kwargs)
     52 if self._ready:
     53     return
---> 54 super()._ipython_display_(**kwargs)

AttributeError: 'super' object has no attribute '_ipython_display_'

什么东西少了? 我需要在 Anaconda.Navigator 的 GUI 中解决这个问题,因为我需要 nglview 作为没有计算科学背景的学生练习的一部分。 我不追求使用 GUI 以外的任何东西的解决方案。 通过 Zoom 要求一组人开始使用 Mac/Windows/Linux 终端进行黑客攻击将是一场噩梦。 非常感谢。

更新最近的努力包括:

  • 关闭并重新启动 Anaconda.Navigator GUI
  • “退出”Jupyter 服务器(浏览器选项卡中的选项)。 重新启动服务器。
  • %conda install -c conda-forge nglview在笔记本的顶部。 它只是告诉我它已经安装好了。
  • 关闭选项卡和所有提及的 Anaconda 和 Jupyter(但不是浏览器 window 实例本身)。

我还没有重新启动机器本身就是一头灰色的大象。 不幸的是,它在后台运行一个长时间的量子化学计算,启动后无法继续:-(对不起。但我不想在重启机器时挂断电话——它不应该归结为那个。

检查你当前conda版本中ipywidget的版本是否在8.0.0以上。 因为 Jupyter notebook 不兼容新版本的ipywidget 因此尝试下面的命令来安装旧版本的ipywidget ,然后应该正确导入 ǹglview` :

conda install "ipywidgets <8" -c conda-forge

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM