Automatically load the ipython extensions running in Jupyter (#2626)

* Automatically load the ipython extensions if we are running in an jupyter notebook

* Only activate inside the ZMQInteractiveShell
This commit is contained in:
Brian Kelley
2019-08-21 08:03:38 -04:00
committed by Greg Landrum
parent e7eca3a8a0
commit 269977f72c

View File

@@ -3,3 +3,16 @@ try:
except ImportError:
__version__ = 'Unknown'
raise
# if we are running in a jupyter notebook, enable the extensions
try:
kernel_name = get_ipython().__class__.__name__
if kernel_name == 'ZMQInteractiveShell':
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import LogWarningMsg, WrapLogs
WrapLogs()
LogWarningMsg("Enabling RDKit %s jupyter extensions"%__version__)
except:
pass