Problem with importing view from crystal_toolkit

I’m trying to follow instructions on the 2019 MP Workshop - Pymatgen foundations.
To visualize CO molecule, I was not able to import view from crystal_toolkit. Here is the error that I get and version of installed Pymatgen and python:

ImportError Traceback (most recent call last)
----> 1 from crystal_toolkit import view

ImportError: cannot import name ‘view’ from ‘crystal_toolkit’ (/Users/iman/.conda/envs/Danalysis/lib/python3.7/site-packages/crystal_toolkit/

print(pymatgen.version): 2020.8.3
print(sys.version): 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 22:45:16) [Clang 9.0.1 ]

The crystal viewer is not a built in jupyter-lab extension. There is a button on the left side of jupyter-lab that looks like a puzzle piece. You can use this to install the extension if crystal_toollkit is already installed. Then in your notebook run import crystal_toolkit and when your structure prints to the cell it will also show the crystal viewer.

Thank you Shyamd for your response. I followed your lead and add extensions as you described.
Now I can see crystaltoolkit-extension installed, I restarted Jupytelab and kernel. Yet still I have the same error while trying to from crystal_toolkit import view.
I tried import crystal_toolkit but I can not still view the structure.

You don’t run that code anymore. That tutorial is outdated as crystal_toolkit has changed.

if your structure is called struc. You can just return that in a cell:


There should be no print or view or anything else.

When I return my_molecule in a cell, I can just see information about the structure.

Molecule Summary Site: C (0.0000, 0.0000, 0.0000) Site: O (0.0000, 0.0000, 1.2000)

  • @module: “pymatgen.core.structure”
  • @class: “Molecule”
  • charge: 0
  • spin_multiplicity: 1

Should I change anything in Jupyter lab to be able to view the figure? Like changing view to see it another tab?

Hi @ivazzade, molecule support is in the main branch, but has not been released on pip yet. Latest installation and usage instructions for Jupyter integration are in the repo, for some reason the website docs weren’t updated from that. I plan to address both this week.

@ivazzade did you manage to solve the program with from crystal_toolkit import view? I am trying to use from pymatgen.vis.structure_chemview import quick_view but without success. This is the test code I’m working on.

from pymatgen.core.structure import Structure
from pymatgen.vis.structure_chemview import quick_view

lattice = [[3, 0, 0], [0, 3, 0], [0, 0, 3]]
species = [“C”, “C”]
coords = [[0, 0, 0], [1.5, 1.5, 1.5]]
structure = Structure(lattice, species, coords)


and this is the error: -------------------------------------------- -------------------------------
AttributeError Traceback (most recent call last)
File c:\users\catiq\appdata\local\programs\python\python38\lib\site-packages\IPython\core\, in, obj)
920 method = get_real_method(obj, self.print_method)
921 if method is not None:
→ 922 method()
923 return True

File c:\users\catiq\appdata\local\programs\python\python38\lib\site-packages\chemview\, in RepresentationViewer.ipython_display(self, **kwargs)
177 def ipython_display(self, **kwargs):
→ 178 super(RepresentationViewer, self).ipython_display(**kwargs)
179 self.displayed = True

AttributeError: ‘super’ object has no attribute ‘ipython_display

If anyone has any tips!

Thread closed due to inactivity, please open a new thread to address related issues.