Search code examples
pythonvirtual-machineattributeerrorpyautogui

How do I use pyautogui on Virtual machine?


I have a piece of the code that works just fine on my PC:

updated=0
while updated==0:
      w=pyautogui.getWindows()
      lw=list(w)
      if strg in lw:
          time.sleep(1)
      else:
          updated=updated+1
          time.sleep(0.1)
          pyautogui.press('enter')
          break

But when I run it on Oracle's VM VirtualBox, I get the error:

AttributeError: module 'pyautogui' has no attribute 'getWindows'

I tried reinstalling PyAutoGui and looking for files with the same name, but it didn't work. Can someone help me solve this error?


Solution

  • To understand the difference between your PC and the VirtualBox, check on both:

    1. Path to the module print(pyautogui.__file__)

    2. Version of the module print(pyautogui.__version__)

    3. Available methods/attributes of the module print(dir(pyautogui))

    It's possible you could use pyautogui.getAllWindows() instead of pyautogui.getWindows()