pythonpyautoguipyscreeze

Pyautogui.displayMousePosition()


Im having issues with pyautogui.

pyautogui.displayMousePosition()
Press Ctrl-C to quit.
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    pyautogui.displayMousePosition()
  File "C:\Users\maxwe\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyautogui\__init__.py", line 1759, in displayMousePosition
    pixelColor = pyscreeze.screenshot().getpixel(
NameError: name 'pyscreeze' is not defined

I've done research on pyscreeze and i don't know what the issue is, everything should be installed correctly and pyautogui does work in some cases

pyautogui.displayMousePosition
<function displayMousePosition at 0x000001D6E8C95760>

both with "import pyautogui" Im just tryna figure out my mouse position so i can write a program with clicking, am i doing anything wrong?


Solution

  • The reason it works in the second case is that you are printing the displayMousePosition attribute of pyautogui instead of calling the function; the printed
    <function displayMousePosition at 0x000001D6E8C95760> tells you that displayMousePosition is a function.
    However, if you add the parenthesis,
    pyautogui.displayMousePosition()
    you effectively call this function, wich relies on pyscreeze, and since there is apparently an issue in your installation with this module you get an error.