I would like to send a docx file to a printer. So, with the win32api, "normally" it should works (QGIS 3.10). In a python plugin, i try to import the win32api

import win32api

ImportError: DLL load failed The specified module could not be found

I've tried in python console, same result. I've tried in python console to get all available modules with help('module'), this time i have a new error :

Traceback (most recent call last): The specified file could not be found
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\console\console_sci.py", line 435, in keyPressEvent
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\console\console_sci.py", line 603, in entered
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\console\console_sci.py", line 616, in runCommand
    import webbrowser
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 784, in _import
    _import_paths[p] = _AddDllDirectory(p)
  File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 731, in _errcheck_zero
    raise ctypes.WinError(ctypes.get_last_error())
FileNotFoundError: [WinError 2]

Impossible to render directly to a printer my docx file :(

  • I don't see the relation to GIS - could you elaborate?
    – Erik
    Aug 20, 2021 at 13:57
  • @Erik : I wrote a plugin for QGIS which generates a Word file.
    – TrsBar
    Aug 20, 2021 at 14:20
  • Can you provide a minimum example?
    – Erik
    Aug 21, 2021 at 10:39
  • @Erik It's easy to reproduce, import win32api always failed. But, the module seems to be avalaible because help('module') appears well.
    – TrsBar
    Aug 23, 2021 at 6:25
  • Why are your requesting the help for a module named 'module'? Anyway, are you sure the package python3-pywin32 is installed in your QGIS Python installation? Aug 23, 2021 at 10:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.