How to fix "AttributeError(name) from None" when trying to use "Button.Left" in pynput

Question:

I am using pynput and am trying to get the mouse to click, for which I import from pynput:

from pynput.mouse import Button, Controller

Then in line 8, I do this:

button = Button.Left

And as a result, I get this error:

Traceback (most recent call last):
  File "C:/FILEPATH.py", line 8, in <module>
button = Button.Left
      File "C:Program Files (x86)PythonPython37-32libenum.py", line 346, in __getattr__
raise AttributeError(name) from None
    AttributeError: Left

Do you know what I am doing wrong, or what’s missing here?

Asked By: JMP

||

Answers:

Just looking at the docs, it should be Button.left with a lowercase l rather than Button.Left with an uppercase l.

Answered By: iz_
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.