Python 'No module named win32gui' after installing pywin32

Viewed 32896

Running python 3.6 on windows 8.

ModuleNotFoundError: No module named 'win32gui'

I have tried multiple installations of pywin32 but none have worked so far. https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/ goes through installation without problems but the issue persuades. Same with pip installing: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32

In my Python root there is now multiple pywin32/win32 variants in the site-packages folder. pywin32.pth doesn't contain a win32gui but only the following:

# .pth file for the PyWin32 extensions win32 win32\lib Pythonwin

I could as a last resort switch to another GUI toolkit but as I'm using some opensource code that would mean I'd have to rewrite lots of code which is why it is a last resort.

Update: changing the import line from:

import win32gui, win32ui, win32con, win32api

To:

from win32 import win32gui, win32ui, win32con, win32api

Pushed the error to:

ImportError: cannot import name 'win32ui'

Solution update:

from win32 import win32gui
import win32ui, win32con, win32api
2 Answers
from win32.win32gui import FindWindow, GetWindowRect, MoveWindow

I guess the standard model name is win32, so all the tutorial on web is outdated. For whatever said before v300, add"win32." before the model name to give a parent modelname which is "win32"

Related