Windows Openbabel Error

128 views
Skip to first unread message

Richard O

unread,
Feb 9, 2023, 9:40:58 AM2/9/23
to PyInstaller
All,

I've been trying to build a very simple openbabel example script but pyinstaller fails to set environment variables or include plugin data causing an error at runtime. 

 .\dist\obopt.exe
==============================
*** Open Babel Error  in OpenBabel::OBPlugin::LoadAllPlugins
  Unable to find OpenBabel plugins. Try setting the BABEL_LIBDIR environment variable.
==============================
*** Open Babel Error  in OpenBabel::OBPlugin::LoadAllPlugins
  Unable to find OpenBabel plugins. Try setting the BABEL_LIBDIR environment variable.

This is the script I am trying to build:

from openbabel import openbabel

class ob:
    def read_xyz(file):
        obconversion = openbabel.OBConversion()
        obconversion.SetInAndOutFormats("xyz", "xyz")
        mol = openbabel.OBMol()
        obconversion.ReadFile(mol, file)
        return mol
    def write_xyz(mol,file):
        obff=openbabel.OBForceField.FindForceField("Ghemical")
        obff.Setup(mol)
        obff.ConjugateGradients(10000)
        obff.GetCoordinates(mol)
        obconversion = openbabel.OBConversion()
        obconversion.SetInAndOutFormats("xyz", "xyz")
        obconversion.WriteFile(mol, file)

mol = ob.read_xyz('test.xyz')


I found an earlier post attempting to solve this issue here: https://github.com/ssorgatem/pyinstaller/blob/master/support/rthooks/pyi_rth_obdata.py

I think this adds a new runtime hook in C:\Users\RO\Miniconda3\envs\ncapB\lib\site-packages\PyInstaller\hooks\rthooks\

I've also tried to supply the hook at build time with: pyinstaller --onefile --runtime-hook=obrth.py .\obopt.py

So far things are still not working. Build works on linux only windows is broken. I am running pyinstaller 5.7.0, python 3.10.8, openbabel  3.1.0. All installed with miniconda.

Any help would be appreciated.

Thanks,
Richard  

Reply all
Reply to author
Forward
0 new messages