我正在尝试关注this,但它失败了
import MDAnalysis as mda
import nglview as nv
from nglview.datafiles import PDB, XTC
u = mda.Universe(PDB, XTC)
protein = u.select_atoms('protein')
当我尝试做的时候:
w = nv.show_mdanalysis(protein)
w
我明白了:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-499e28f0ffd3> in <module>()
----> 1 w = nv.show_mdanalysis(protein)
2 w
~/anaconda3/lib/python3.6/site-packages/nglview-0.4-py3.5.egg/nglview/__init__.py in show_mdanalysis(atomgroup, **kwargs)
118 '''
119 structure_trajectory = MDAnalysisTrajectory(atomgroup)
--> 120 return NGLWidget(structure_trajectory, **kwargs)
121
122
~/anaconda3/lib/python3.6/site-packages/nglview-0.4-py3.5.egg/nglview/__init__.py in __init__(self, structure, trajectory, representations, parameters, **kwargs)
347 if parameters:
348 self.parameters = parameters
--> 349 self.set_structure(structure)
350 if trajectory:
351 self.trajectory = trajectory
~/anaconda3/lib/python3.6/site-packages/nglview-0.4-py3.5.egg/nglview/__init__.py in set_structure(self, structure)
372 def set_structure(self, structure):
373 self.structure = {
--> 374 "data": structure.get_structure_string(),
375 "ext": structure.ext,
376 "params": structure.params
~/anaconda3/lib/python3.6/site-packages/nglview-0.4-py3.5.egg/nglview/__init__.py in get_structure_string(self)
313 "'MDAnalysisTrajectory' requires the 'MDAnalysis' package"
314 )
--> 315 import cStringIO
316 u = self.atomgroup.universe
317 u.trajectory[0]
ModuleNotFoundError: No module named 'cStringIO'
答案 0 :(得分:1)
我会尝试通过conda(和Anaconda distribution)获得干净的nglview安装:
尝试使用
卸载nglviewconda remove nglview
以防万一有一个旧版本。如果此conda删除失败,则说明该软件包可能是pip
或easy_installed
。尝试pip remove nglview
。如果仍然不能解决问题,则必须查找已安装的nglview软件包,并使用rm
手动将其删除,但是我不想在此处放置复制和粘贴说明,因为这需要仔细查看文件。
所有nglview痕迹均已删除后,请使用conda
安装最新版本的nglview from the conda-forge channel:
conda install -c conda-forge nglview