The following example works fine if it is run directly from the python file.
import streamlit as st
from rdkit import Chem
from rdkit.Chem import Draw
compound_smiles = 'C'
list_compounds = [Chem.MolFromSmiles(compound_smiles)]
fig = Draw.MolsToGridImage(list_compounds, legends = ['methane'],
molsPerRow = 1, maxMols = 1)
If it is run with streamlit, it produces the following error:
ArgumentError: Python argument types in MolDraw2D.DrawMolecules(MolDraw2DCairo, list) did not match C++ signature: DrawMolecules(RDKit::MolDraw2D {lvalue} self, boost::python::api::object mols, boost::python::api::object highlightAtoms=None, boost::python::api::object highlightBonds=None, boost::python::api::object highlightAtomColors=None, boost::python::api::object highlightBondColors=None, boost::python::api::object highlightAtomRadii=None, boost::python::api::object confIds=None, boost::python::api::object legends=None)
Traceback:
File "/home/lili/SDSC/Projects/MSEI/raw-data-preprocessing/conda-env-full/lib/python3.7/site-packages/streamlit/ScriptRunner.py", line 322, in _run_script
exec(code, module.__dict__)
File "/home/lili/SDSC/Projects/MSEI/raw-data-preprocessing/trystuff/rdkit-streamlit-minimalexample.py", line 9, in <module>
molsPerRow = 1, maxMols = 1)
File "/home/lili/SDSC/Projects/MSEI/raw-data-preprocessing/conda-env-full/lib/python3.7/site-packages/rdkit/Chem/Draw/__init__.py", line 497, in MolsToGridImage
highlightBondLists=highlightBondLists, **kwargs)
File "/home/lili/SDSC/Projects/MSEI/raw-data-preprocessing/conda-env-full/lib/python3.7/site-packages/rdkit/Chem/Draw/__init__.py", line 443, in _MolsToGridImage
highlightBonds=highlightBondLists, **kwargs)
Any idea how this could be solved?
Thanks in advance!