Tuesday, 13 July 2021

Pyinstaller: How to solve relative import error if occurs in third-party libraries

I'm currently trying to create an executable for my application with Pyinstaller. I already could fix some general import errors by including the respective libraries in the hiddenimports section in my .spec file.

However I'm now getting the following error when executing my .exe:

ImportError: attempted relative import with no known parent package

Looking at the Traceback it seems like my used package (sklearn) is using relative imports. Reading through similar questions, I only found solutions for this problem in case relative imports are needed in the own package. But how to solve the problem when it occurs in a package which I'm not able to adapt?

I tried to add sklearn and the respective subpackages (e.g.sklearn.utils.fixes) explicitely in hiddenimports but this didn't work.

Thank you in advance for your support!

Best Regards!



from Pyinstaller: How to solve relative import error if occurs in third-party libraries

No comments:

Post a Comment