import FreeCAD DLL load failed why???

hi there
I am using FC0.18.
I tryed to add something to FreeCAD by using a small program generated by pyinstaller.
The py env version is the same as FC0.18 python version which is python3.6.6.
In one of the script I import the FreeCAD module but it turned out to be an importerror 【“DLL load failed”】. I had appended “FreeCAD/bin” to sys.path and os.env[‘path’] in the script . I am able to import FreeCAD in a console or using pycharm if I add “FreeCAD/bin” to sys.path.

In FC 0.19 I tried the method( os.add_dll_directory ) to add the dll to the path and it was imported successfully. But this method was picked up by python since Python3.8. If I change my virtual env python version to 3.8 in FC 0.18 the FC would cause conflicts with that.

I had appended “FreeCAD/bin” to sys.path and os.env[‘path’] in the script .

“FreeCAD/bin” is a relative path and your script presumably isn’t a sibling file to the FreeCAD directory. Either make sure the path is relative to the location of the script file or use absolute paths.

Thanks. To clarified : I had added the freecad/bin absolute path to sys.path and os.environ[‘path’].