Sometimes you want to see the 3D structure of molecule you are manipulating in jupyter, but you have to save it as a file with coordinates and open it in PyMol. This is very inconvenient. Although you can use PyMol to render image and show it in jupyter, but it is only a static image. Here I recommand a python package py3Dmol, which is a simple jupyter widget based on a JavaScript library 3Dmol.js. JavaScript can run in almost any browser, so you can use it in jupyter notebooks and in web pages.
More detail usage can be found on 3Dmol.js offical documents, returned viewer has exact same api as 3Dmol.GLViewer
More Examples
With ipywidgets.IntSlider
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from ipywidgets import interact,fixed,IntSlider import ipywidgets
smis = [ 'COc3nc(OCc2ccc(C#N)c(c1ccc(C(=O)O)cc1)c2P(=O)(O)O)ccc3C[NH2+]CC(I)NC(=O)C(F)(Cl)Br', 'CC(NCCNCC1=CC=C(OCC2=C(C)C(C3=CC=CC=C3)=CC=C2)N=C1OC)=O', 'Cc1c(COc2cc(OCc3cccc(c3)C#N)c(CN3C[C@H](O)C[C@H]3C(O)=O)cc2Cl)cccc1-c1ccc2OCCOc2c1', 'CCCCC(=O)NCCCCC(=O)NCCCCCC(=O)[O-]', "CC(NCCNCC1=CC=C(OCC2=C(C)C(C3=CC=CC=C3)=CC=C2)N=C1OC)=O"] confs = [smi2conf(s) for s in smis]