Search code examples
pythonpyinstallerpython-importpywin32

pyinstaller cant detect 'win32api' module even after --hidden-import


Im trying to convert a simple python program to exe but pyinstaller doesnt detect 'win32api' and keeps giving me ModuleNotFoundError: No module named 'win32api'

Here is the app btw:

import time
import win32api


def minutes():
    time.sleep(600)
    win32api.MessageBeep()
    win32api.MessageBox(0, '10 Minutes Have Passed', '10 Minutes ')
    time.sleep(5)
    hour()


def hour():
    time.sleep(3600)
    win32api.MessageBeep()
    win32api.MessageBox(0, '1 Hour Has Passed', '1 Hour ')
    time.sleep(5)

    minutes()


hour()

What i tried: tried using pyinstaller --onefile --hidden-import win32api nameoftheapp. (tried --hidden-import=win32api too)
Also tried just modifying .spec file to include hiddenimports=['win32api'].


Solution

  • try using pywin32 instead for the hidden import; i believe that's the same package but goes by a variety of names for whatever complicated reasons...