Search code examples
python-3.ximporterrorpynput

ModuleNotFoundError: No module named 'pynput.Keyboard'


I cannot import pynput I did the pip install and this is the error:

from pynput.Keyboard import Key
ModuleNotFoundError: No module named 'pynput.Keyboard'

and when I try to download it again is says: Requirement already satisfied

Im using python 3.7

this is the code if it helps:

from pynput.Keyboard import Key
from pynput.Keyboard import Controller


KeyBoard = Controller()
KeyBoard.press('a')
KeyBoard.release('a')

Solution

  • keyboard is lowercase. So your code should be:

    from pynput.keyboard import Key
    from pynput.keyboard import Controller
    
    KeyBoard = Controller()
    KeyBoard.press('a')
    KeyBoard.release('a')