PyInstaller, spec file, ImportError: No module named ‘blah’

The problem is that pyinstaller won’t see second level imports. So if you import module A, pyinstaller sees this. But any additional module that is imported in A will not be seen.

There is no need to change anything in your python scripts. You can directly add the missing imports to the spec file.
Just add the following in a = Analysis(...):

hiddenimports=["mysql"],

This should be the result:

a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'icinga.py'],
         pathex=['/home/user/projects/icinga_python/releases/v2.1'], hiddenimports=["mysql"],)

After that run pyinstaller with the spec file as an argument.

Leave a Comment