xralf
xralf

Reputation: 3652

ImportError: DLL load failed while importing win32print

I have the following code

from win32 import win32print

for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL, None, 1):
            _, _, name, _ = p
            print (name)

The code works. I'm trying to create an exe file from it as follows:

cd C:\Users\xralf\AppData\Local\Programs\Python\Python38-32\Scripts
pyinstaller.exe --onefile C:\Users\xralf\Desktop\enumprinters.py
cd dist
enumprinters.exe

It writes the following error message:

ImportError: DLL load failed while importing win32print: The specified module could not be found.

How can I fix it?

Upvotes: 2

Views: 1185

Answers (1)

jizhihaoSAMA
jizhihaoSAMA

Reputation: 12672

There are three ways I know maybe can solve your problem:

  1. Update your pyinstaller.
  2. Update your pywin32.
  3. Try to find what's the dll it needed.(In /build/name/warnname.txt).And use pyinstaller --add-binary 'the_path_of_dll:.' myscript.py
  4. If you are using python 3.8,Please use the old version.I heard that pyinstaller worked not very well in python 3.8.

Upvotes: 1

Related Questions