有没有办法在 python 中调用 PubChem API?

Is there anyway to call PubChem API In python?

我一直在使用 PubChem API 将 Chemical smile 转换为结构,但仍然有错误。

这是我的 google colab 我尝试使用 PIL 图像加 TKinter

https://colab.research.google.com/drive/1TE9WxXwaWKSLQzKRQoNlWFqztVSoIxB7

我想要的输出应该是这样的结构格式

https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/O=C(N1C=CN=C1)N2C=CN=C2/PNG?record_type=2d&image_size=large

下载并在 Jupyter Notebook 中显示

from urllib.request import urlretrieve
from IPython.display import Image

smiles = 'NC1=NC(C)=C(C2=CC=C(S(=O)(C)=O)C(F)=C2)S1'
urlretrieve('https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/'+smiles+'/PNG', 'smi_pic.png')
p = Image(filename='smi_pic.png')
p

输出