Open mol file error

Hi,
I had a python script where I try to import a molecule from a mol file:
mol = Molecule.from_file(‘YINRAQ_0.mol’)

This used to work but I changed my conda environment after the latest CSD release and now this line returns the following error. I do not know how to fix this or what is causing the error. I have double checked that the file exists. I’ve tried reverting back to the version of pymatgen I used but it was from the matsci channel which nolonger works.

Traceback (most recent call last):

File “C:\Users\mjkiwsw4\Python_Scripts\Vasp\EthylAcetate_Solvates\supercell\YINRAQ\VASP-supercell2.py”, line 13, in
mol = Molecule.from_file(‘YINRAQ_0.mol’)

File “C:\Users\mjkiwsw4\AppData\Local\Continuum\anaconda3\envs\CSD-env\lib\site-packages\pymatgen\core\structure.py”, line 2895, in from_file
m.group(1)).pymatgen_mol

File “C:\Users\mjkiwsw4\AppData\Local\Continuum\anaconda3\envs\CSD-env\lib\site-packages\pymatgen\io\babel.py”, line 319, in from_file
mols = pb.readfile(str(file_format), str(filename))

AttributeError: ‘NoneType’ object has no attribute ‘readfile’

Hi @SarahEW,

I suspect you may not have Open Babel (or perhaps “pybel”) installed? This is a dependency of pymatgen, meaning that it has to be installed for some parts of pymatgen to work correctly.

I’m not current on the easiest way to install these, perhaps conda will work. We’re trying to move away from Open Babel particularly because it can be difficult to install. If you had your molecules in e.g. xyz format instead of mol format this would not require Open Babel.

Best,

Matt