Search code examples
pythonpython-3.xpynput

"ImportError: No module named pynput.keyboard" in Python 3


I have installed python3.8.2 with pip3 version 20.01 and pynput version 1.6.8 is also installed and configured.

OS used is Windows

IDE: PyCharm

launch file on: PyCharm run

import pynput.keyboard


def process_key_press(key):
    print(key)


keyboard_listener = pynput.keyboard.Listener(on_press=process_key_press)
with keyboard_listener:
    keyboard_listener.join()

Error there is error in:

import pynput.keyboard

Solution

  • PyCharm creates a new virtual environment for each project by default. You have two choices: