'Pyinstaller not working - ImportError: Module 'pywintypes' isn't in frozen sys.path

C:\Users\CENSORED\AppData\Local\Programs\Python\Python37-32\ReworkX\dist\RAN_HelperTEST>RAN_HelperTEST.exe
Traceback (most recent call last): File
"PyInstaller\hooks\rthooks\pyi_rth_win32api.py", line 20, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 540, in
exec_module File "pywintypes.py", line 136, in <module> File
"pywintypes.py", line 61, in __import_pywin32_system_module__
ImportError: Module 'pywintypes' isn't in frozen sys.path
['C:\\Users\\CENSORED\\AppData\\Local\\Programs\\Python\\Python37-32\\ReworkX\\dist\\RAN_HelperTEST\\base_library.zip',
'C:\\Users\\CENSORED\\AppData\\Local\\Programs\\Python\\Python37-32\\ReworkX\\dist\\RAN_HelperTEST\\lib-dynload',
'C:\\Users\\CENSORED\\AppData\\Local\\Programs\\Python\\Python37-32\\ReworkX\\dist\\RAN_HelperTEST']
[21672] Failed to execute script pyi_rth_win32api

The above is the error when I try to execute. There's not a pyi_rth_win32api anywhere in the new dist or build folders created - but it exists in \Lib\site-packages\PyInstaller\Hooks\rthooks

The date for the creation of that file in the hooks folder is today from after I ran pyinstaller, so it never existed before anywhere. Why is it creating that and trying to add it and causing the pyinstaller to fail?

Is OS outdated?

In site packages, there's are win32, win32com, win32comext, and win32ctypes directories.

None of them have pyi_rth_win32api.

Going through the text that came up when I first ran Pyinstaller, I notice some warnings that might be related?

Such as:

46049 WARNING: lib not found: pywintypes37.dll dependency of
c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\win32wnet.pyd
46081 WARNING: lib not found: pywintypes37.dll dependency of
c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\win32api.pyd
46187 WARNING: lib not found: pywintypes37.dll dependency of
c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\win32pdh.pyd

also:

Traceback (most recent call last):   File "<string>", line 3, in
<module>   File
"c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\utils\win32\winutils.py",
line 97, in import_pywin32_module
    module_name, globals={}, locals={}, fromlist=[''])   File "c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\pythoncom.py",
line 2, in <module>
    import pywintypes   File "c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\lib\pywintypes.py",
line 136, in <module>
    __import_pywin32_system_module__("pywintypes", globals())   File "c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\lib\pywintypes.py",
line 64, in __import_pywin32_system_module__
    import _win32sysloader ImportError: DLL load failed: %1 is not a valid Win32 application. 44334 INFO: Loading module hook
'hook-pywintypes.py' from
'c:\\users\\CENSORED\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
Traceback (most recent call last):   File "<string>", line 3, in
<module>   File
"c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\utils\win32\winutils.py",
line 97, in import_pywin32_module
    module_name, globals={}, locals={}, fromlist=[''])   File "c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\lib\pywintypes.py",
line 136, in <module>
    __import_pywin32_system_module__("pywintypes", globals())   File "c:\users\CENSORED\appdata\local\programs\python\python37-32\lib\site-packages\win32\lib\pywintypes.py",
line 64, in __import_pywin32_system_module__
    import _win32sysloader ImportError: DLL load failed: %1 is not a valid Win32 application.

If anyone could please help me - I'm trying to create an executable to share a script I wrote with other users at work who do not use python.

Also - The script starts with a user input line. Not sure if that could be related?



Solution 1:[1]

Your application is missing one dll file: pywintypes37.dll

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kursun