How to display rdkit molecules on streamlit

Hi, I am trying to deploy a web app using streamlit but I am having trouble getting some dependencies to work. I’m using the RDkit python package which allows to display molecules, but when I try to deploy my app, it gives me this error:

Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.7/site-packages/streamlit/", line 338, in _run_script
    exec(code, module.__dict__)
  File "/app/bioinformatics-project-nn/bioactivity-prediction-app/", line 7, in <module>
    from rdkit.Chem import MACCSkeys, Draw
  File "/home/appuser/venv/lib/python3.7/site-packages/rdkit/Chem/Draw/", line 14, in <module>
    from rdkit.Chem.Draw import rdMolDraw2D
ImportError: cannot open shared object file: No such file or directory

Any idea how this could be solved?

Thanks in advance!

Hi @jkim1000, welcome to the Streamlit community!! :wave: :partying_face:

I’m sorry to hear you’re running into dependency issues on Streamlit sharing. It looks like you have discovered a bug!

The idea is that if your, requirements.txt, and packages.txt files are not in the root of your GitHub repo, and are instead within a folder, say, bioactivity-prediction-app/, the dependencies from packages.txt are not installed! Moving the three files to the root of your repo should fix the issue for now.

I’ve created a bug report and brought this issue to the attention of our engineering team. I’ll update you once the issue is resolved.

For now, here’s how you can fix the import errors:

  1. Delete environment.yml
  2. Delete bioactivity-prediction-app/conda.txt
  3. Move, packages.txt, and requirements.txt to the root of the repo
  4. Update any file paths in to point to updated locations for data and models
  5. Edit packages.txt to contain only libxrender1. The rdkit-pypi package requires libxrender1 and not the other packages currently in your packages file.
  6. Delete your app on sharing
  7. Deploy a new app on sharing with the updated

Let me know if this helps!

Happy Streamlit-ing! :balloon: