0

As a beginner in Python, I really don't know what I'm doing wrong here?

I would like to work with pyautogui:

 >>> import pyautogui
 >>> pyautogui.PAUSE = 1
 >>> pyautogui.FAILSAFE = True
 >>> pyautogui.size()
 Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    pyautogui.size()
 AttributeError: module 'pyautogui' has no attribute 'size'

Don't know why it doesn't show my resolution? And in general, pyautogui doesn't work with commands like:

 >>> pyautogui.moveTo(100, 100, duration=0.25)
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    pyautogui.moveTo(100, 100, duration=0.25)
AttributeError: module 'pyautogui' has no attribute 'moveTo'
>>> 

I'm sure I installed pip.

ZF007
  • 3,708
  • 8
  • 29
  • 48
MaxD
  • 1
  • 1
  • 4
    Have you named a script "pyautogui.py" somewhere? – DavidG Oct 29 '18 at 11:47
  • Ive made a pyautogui.py in Windows 10 C:\Users\xxxxx\AppData\Local\Programs\Python\Python37\pyautogui.py – MaxD Oct 29 '18 at 11:52
  • You need to rename that to something else. Python thinks that the .py file you saved is the pyautogui module – DavidG Oct 29 '18 at 11:53
  • == RESTART: C:\Users\xxx\AppData\Local\Programs\Python\Python37\123.py == Traceback (most recent call last): File "C:\Users\xxx\AppData\Local\Programs\Python\Python37\123.py", line 1, in import pyautogui ModuleNotFoundError: No module named 'pyautogui' – MaxD Oct 29 '18 at 12:18
  • I think the way you've learned what a module etc is, might be wrong. Naming **your** script and then automatically do `import pyautogui` won't work. And having pip installed doesn't actually do anything. Pip is a tool to install packages/libraries, such as `pip install pyautogui` would install it. Then you name your script `maxd.py` and do `import pyautogui`. But having pip installed and then just doing `import X` won't do anything, it's not a "when i run something, and i don't have the lib, pip will fix it for me". It's not like IntelliJ/Gradle in Java, if that's your background. – Torxed Oct 29 '18 at 20:33

1 Answers1

0

Your own script which is named "pyautogui.py" is interfering with the module you installed — so rename it something else.

martineau
  • 119,623
  • 25
  • 170
  • 301