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)
in
----> 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/init.py)

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:

struc

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)
root:

  • @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.