{"id":10189,"library":"rdkit-pypi","title":"RDKit for Python (PyPI)","description":"RDKit is a collection of chemoinformatics and machine-learning software written in C++ and Python. The `rdkit-pypi` package provides pre-built wheels for the RDKit library, enabling easy installation via pip on various platforms and Python versions. This addresses common build issues encountered with the upstream RDKit PyPI package, which often only provides source distributions. It follows a rapid release cadence, syncing with RDKit's development.","status":"active","version":"2026.03.01","language":"en","source_language":"en","source_url":"https://github.com/kuelumbus/rdkit-pypi","tags":["cheminformatics","chemistry","drug-discovery","machine-learning","molecular-modeling"],"install":[{"cmd":"pip install rdkit-pypi","lang":"bash","label":"Install RDKit pre-built wheels"}],"dependencies":[],"imports":[{"symbol":"Chem","correct":"from rdkit import Chem"},{"symbol":"AllChem","correct":"from rdkit.Chem import AllChem"},{"symbol":"DataStructs","correct":"from rdkit import DataStructs"},{"note":"Drawing utilities are typically in rdkit.Chem.Draw","wrong":"from rdkit.Chem import MolsToGridImage","symbol":"MolsToGridImage","correct":"from rdkit.Chem.Draw import MolsToGridImage"},{"note":"Required to render molecules directly in Jupyter notebooks; often imported for side effects.","symbol":"IPythonConsole","correct":"from rdkit.Chem.Draw import IPythonConsole"}],"quickstart":{"code":"from rdkit import Chem\nfrom rdkit.Chem.Draw import MolsToGridImage\n\n# Create a molecule from SMILES string\nmol1 = Chem.MolFromSmiles('CCO')\nmol2 = Chem.MolFromSmiles('c1ccccc1')\n\nprint(f\"SMILES for ethanol: {Chem.MolToSmiles(mol1)}\")\nprint(f\"SMILES for benzene: {Chem.MolToSmiles(mol2)}\")\n\n# Generate an image grid (requires matplotlib and pillow, often pre-installed)\nimg = MolsToGridImage([mol1, mol2], molsPerRow=2, subImgSize=(200, 200))\n# In a Jupyter environment, img would display directly\n# If not in Jupyter, you might save it: img.save('molecules.png')","lang":"python","description":"This example demonstrates how to create RDKit molecule objects from SMILES strings, convert them back to SMILES, and visualize them as a grid image. Ensure you have matplotlib and pillow installed for image generation."},"warnings":[{"fix":"Always use `pip install rdkit-pypi` for easy installation with pre-built wheels.","message":"Many users incorrectly attempt to install the upstream `rdkit` package directly via `pip install rdkit`. The official `rdkit` package on PyPI typically only provides source distributions, leading to build errors without specific C++ dependencies and compilers. The `rdkit-pypi` package provides pre-built wheels, making `pip install rdkit-pypi` the recommended method for pip users.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use a dedicated virtual environment and stick to a single installation method (either `conda` or `pip install rdkit-pypi`).","message":"Mixing RDKit installations (e.g., `conda install rdkit` and `pip install rdkit-pypi`) in the same Python environment can lead to linker errors, module conflicts, or unexpected behavior due to different underlying C++ libraries.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the official RDKit release notes and migration guides when upgrading across major RDKit versions. Test your code thoroughly after upgrades.","message":"The RDKit API can evolve between major releases, leading to deprecations or changes in function signatures, class constructors, or module locations. `rdkit-pypi` versions closely track RDKit releases, so these changes apply.","severity":"breaking","affected_versions":"All major RDKit release boundaries (e.g., 2023.09.x to 2024.03.x)"},{"fix":"Optimize your code for memory efficiency, process data in batches, and ensure your system has sufficient RAM for computationally intensive tasks. Consider using RDKit's C++ API for extreme cases or distributed computing.","message":"Processing very large molecules, extensive conformer generation, or high-throughput calculations/drawing without proper memory management can lead to significant memory consumption and potential `MemoryError` or `Segmentation fault` crashes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure `rdkit-pypi` is correctly installed: `pip install rdkit-pypi`. Verify your Python environment is active where it was installed.","cause":"The `rdkit` library (or `rdkit-pypi`) is not installed in the current Python environment, or a previous `pip install rdkit` attempt failed to build the package.","error":"ImportError: No module named 'rdkit'"},{"fix":"Validate your input SMILES strings before passing them to functions like `Chem.MolFromSmiles()`. Use a `try-except` block to gracefully handle potential parsing errors or check for `None` return values: `mol = Chem.MolFromSmiles(smiles_string); if mol is None: print('Invalid SMILES')`.","cause":"An attempt was made to create a molecule from an invalid or malformed SMILES string.","error":"[CRITICAL] RDKit Error: C++ exception: Bad SMILES"},{"fix":"Ensure you are importing from the correct submodule, typically `rdkit.Chem.Draw`. For older RDKit versions, some drawing functions might have been in `rdkit.Chem` directly or have different names. Upgrade `rdkit-pypi` to the latest version: `pip install --upgrade rdkit-pypi`.","cause":"The specific function `MolsToGridImage` or other drawing utilities are not found. This might be due to an older RDKit version or an incorrect import path.","error":"AttributeError: module 'rdkit.Chem.Draw' has no attribute 'MolsToGridImage'"}]}