Search code examples
pythonwindowspyinstaller

How can I avoid Pyinstaller import win32clipboard error?


I use PyInstaller (Win 10) to create a text analyzing app. But though it works fine in Visual Studio Code, the exe file creates an error.

I use:

pyinstaller --onefile textanalyzer_02.py

But starting the exe file gives me the following error:

Traceback (most recent call last):
  File "textanalyzer_02.py", line 2, in <module>
    import win32clipboard
ImportError: DLL load failed while importing win32clipboard: Das angegebene Modul wurde nicht gefunden.
[7604] Failed to execute script textanalyzer_02

I tried also:

pyinstaller --onefile textanalyzer_02.py --hidden-import win32clipboard

But it didn't work either. Any ideas?


Solution

  • Came across this while having the same issue. Found a solution that worked for me. I imported pywintypes into my script before win32clipboard:

    import pywintypes
    import win32clipboard
    

    After that, my compiled program ran again without any errors. Windows 10 / Python 3.8.6 / PyInstaller 4.0.