Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入错误:导入win32print时DLL加载失败_Python_Python 3.x_Winapi_Dll_Pyinstaller - Fatal编程技术网

Python 导入错误:导入win32print时DLL加载失败

Python 导入错误:导入win32print时DLL加载失败,python,python-3.x,winapi,dll,pyinstaller,Python,Python 3.x,Winapi,Dll,Pyinstaller,我有以下代码 from win32 import win32print for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL, None, 1): _, _, name, _ = p print (name) 代码是有效的。 我正试图从中创建一个exe文件,如下所示: cd C:\Users\xralf\AppData\Local\Programs\Python\Pytho

我有以下代码

from win32 import win32print

for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL, None, 1):
            _, _, name, _ = p
            print (name)
代码是有效的。 我正试图从中创建一个exe文件,如下所示:

cd C:\Users\xralf\AppData\Local\Programs\Python\Python38-32\Scripts
pyinstaller.exe --onefile C:\Users\xralf\Desktop\enumprinters.py
cd dist
enumprinters.exe
它写入以下错误消息:

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

我如何修复它?

我知道有三种方法可以解决您的问题:

  • 更新您的
    pyinstaller
  • 更新您的
    pywin32
  • 尝试查找所需的dll。(在/build/name/warnname.txt中)。并使用
    pyinstaller——添加二进制文件“dll的路径:.”myscript.py
  • 如果您使用的是
    python3.8
    ,请使用旧版本。我听说
    pyinstaller
    python3.8
    中工作得不是很好

  • 第一步和第二步为我做了。谢谢