1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
# PubChemPy
[](https://pypi.python.org/pypi/PubChemPy)
[](https://anaconda.org/conda-forge/pubchempy)
[](https://github.com/mcs07/PubChemPy/blob/main/LICENSE)
[](https://zenodo.org/badge/latestdoi/7462957)
[](https://github.com/mcs07/PubChemPy/actions/workflows/test.yml)
[](https://docs.pubchempy.org)
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.
## Installation
Install PubChemPy with pip:
```shell
pip install pubchempy
```
Or with conda:
```shell
conda install -c conda-forge pubchempy
```
For detailed instructions, see the [installation guide](https://docs.pubchempy.org/en/latest/guide/install.html).
## Example usage
Retrieve a compound by its PubChem Compound Identifier (CID) and print its SMILES and IUPAC name:
```pycon
>>> 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 acid
```
Search compounds by name and print the SMILES and molecular weight of the first result:
```pycon
>>> results = pcp.get_compounds("Aspirin", "name")
>>> print(results[0].smiles)
CC(=O)OC1=CC=CC=C1C(=O)O
>>> print(results[0].molecular_weight)
180.16
```
## Documentation
Full documentation is available at <https://docs.pubchempy.org>.
This includes a [step-by-step guide on how to use PubChemPy](https://docs.pubchempy.org/en/latest/guide/gettingstarted.html), as well as a [complete API reference](https://docs.pubchempy.org/en/latest/api.html).
## Contributing
- Feature ideas and bug reports are welcome on the [Issue Tracker](https://github.com/mcs07/PubChemPy/issues).
- Fork the [source code](https://github.com/mcs07/PubChemPy) on GitHub, make changes and file a pull request.
## License
PubChemPy is licensed under the [MIT license](https://github.com/mcs07/PubChemPy/blob/main/LICENSE).
|