Ipyketcher is a widget implementation of the Ketcher chemical structure editor for use in Jupyter notebooks and other environments supporting ipywidgets.

from ipyketcher import KetcherEditor
editor = KetcherEditor(
initial_molecule="OCC",
return_formats=["smiles", "molfile"],
)
editorYou can now draw a structure, and access the currently drawn molecule in smiles or molfile format via
editor.smiles or editor.molfile.
Other supported formats are: 'rxn', 'ket', 'smarts', 'cml', 'sdf', 'cdxml', 'cdx', 'inchi', 'inchi_key'. Set the format you want synchronized back to Python using the return_formats parameter, and observe the output via the corresponding attribute on the KetcherEditor instance.
The example.ipynb has a more elaborate exmaple of usage with RDKit integration.
pip install ipyketcheror with uv:
uv add ipyketcherWe recommend using uv for development. It will automatically manage virtual environments and dependencies for you.
uv run jupyter lab example.ipynbAlternatively, create and manage your own virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
jupyter lab example.ipynbThe widget front-end code bundles it's JavaScript dependencies. After setting up Python, make sure to install these dependencies locally:
npm installWhile developing, you can run the following in a separate terminal to automatically rebuild JavaScript as you make changes:
npm run devOpen example.ipynb in JupyterLab, VS Code, or your favorite editor
to start developing. Changes made in js/ will be reflected
in the notebook.
Creating a new release:
- Bump the version in
pyproject.toml. - Create a new git tag with the version.
- Build and upload the package to PyPI:
npm build
hatch build
hatch publish -u __token__ -a pypi-<your-token>Set anywidget hot reloading on windows:
set ANYWIDGET_HMR=1