1

I'm trying to export a Python file as a .exe file with Pyinstaller. My Python program uses the RDKit package, which is not supported by Pyinstaller by default. I tried to set the flag --hidden-import='rdkit' and I also placed a hook file in the Pyinstaller directory with the code

hiddenimports = [
    "rdkit.*",
    "rdkit.ANY.*"
]

But I'm still getting a bunch of 'lib not found' warnings from Pyinstaller. When I run the .exe file, I get the error

"No such file or directory: 'C:\\Users\\...\\_MEI84842\\rdkit_pypi.libs\\.load-order-rdkit_pypi-2021.9.2' ".

This file is in the rdkit_pypi.libs folder, at the same level as the rdkit folder itself.

Does anyone have a proper hook file for RDKit or know how to set the correct path for the said file?

betelgeuse
  • 1,136
  • 3
  • 13
  • 25

1 Answers1

1

I had the same issue, forcing pyinstaller to add the whole rdkit_pypi.libs folder worked for me. This can be done in two ways :

  • Command Line : add the --add-data parameter with the location of rdkit_pypi.libs folder

     pyinstaller --add-data='C:\Python37\Lib\site-packages\rdkit_pypi.libs;rdkit_pypi.libs' "yourprogam.py"
    
  • Spec file : if you are using a spec file to bundle the application, you can set this in the datas section of the Analysis variable

     a = Analysis(...
          datas=[('C:\\Python37\\Lib\\site-packages\\rdkit_pypi.libs', 'rdkit_pypi.libs')],
          ...
     )
    

I actually didn't need the --hidden-import='rdkit' for it to work.

Hope this will help in your case too.

farameris
  • 31
  • 4