PubChemPy provides a way to interact with PubChem in Python. It allows chemical searches by name, substructure and similarity, chemical standardization, conversion between chemical file formats, depiction and retrieval of chemical properties.
To get the latest version, it is recommended to install from the source directly:
pip install git+https://github.com/mcs07/PubChemPyThis version is not guaranteed to be stable, but may include new features and bug fixes that have not yet been released.
Note: If you installed PubChemPy from pypi in the passed, you must uninstall it before installing the source code version using pip uninstall pubchempy for example
Install PubChemPy with pip:
pip install pubchempyOr with conda:
conda install -c conda-forge pubchempyFor detailed instructions, see the installation guide.
Retrieve a compound by its PubChem Compound Identifier (CID) and print its SMILES and IUPAC name:
>>> import pubchempy as pcp
>>> comp = pcp.Compound.from_cid(1423)
>>> print(comp.smiles)
CCCCCCCNC1CCCC1CCCCCCC(=O)O
>>> print(comp.iupac_name)
7-[2-(heptylamino)cyclopentyl]heptanoic acidSearch compounds by name and print the SMILES and molecular weight of the first result:
>>> results = pcp.get_compounds("Aspirin", "name")
>>> print(results[0].smiles)
CC(=O)OC1=CC=CC=C1C(=O)O
>>> print(results[0].molecular_weight)
180.16Full documentation is available at https://docs.pubchempy.org.
This includes a step-by-step guide on how to use PubChemPy, as well as a complete API reference.
- Feature ideas and bug reports are welcome on the Issue Tracker.
- Fork the source code on GitHub, make changes and file a pull request.
PubChemPy is licensed under the MIT license.