Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python pyautogui AttributeError: 'module' object has no attribute 'size'

import pyautogui
import time

def pause():
    time.sleep(0.001)

while True:
    pyautogui.keyDown('down')


    time.sleep(5)

Gives me error

C:\Python27\python.exe E:/Python/win32/pythongui.py
Traceback (most recent call last):
  File "E:/Python/win32/pythongui.py", line 1, in <module>
    import pyautogui
  File "E:\Python\win32\pyautogui.py", line 45, in <module>
    screenWidth, screenHeight = pyautogui.size()
AttributeError: 'module' object has no attribute 'size'

Process finished with exit code 1

I don't understand why I get this error I don't even call attribute size and yesterday everything worked just fine. Today for some weird reason I keep getting this error. Code is exactly same as before when pyautogui worked.

like image 306
Gunnm Avatar asked Dec 08 '25 07:12

Gunnm


1 Answers

Beacuse you set the file name to pyautogui.py, which apparently conflicts with the package you importing. change your file name and run again Refer this issue: https://github.com/Microsoft/vscode-python/issues/1588

like image 68
kumar Avatar answered Dec 09 '25 21:12

kumar