I installed it with pip install pynput
(i also tried pip3 install
,python -m pip install
)
I am using vs code
it also doesnt work with terminal
pip list says i have pynput 1.7.1
my code:
import Pynput
from pynput.keyboard import Key, Listener
def on_press(key):
print("{0} pressed".format(key))
def on_release(key):
if key == Key.esc:
return False
with Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
The error is:
ModuleNotFoundError: No module named 'Pynput'
I hope the first line is some typing error and you are using import pynput and not Pynput. Pls. import correct module name
Pls. run the
which python
command andpip list
to make sure the installation is correct. Pls. confirm if the python where you are executing this is same python where you have installed (usewhich python
). make sure you are executing in the same virtual env where you have installed basically.Also, if your
pip list
shows the module in the list. Open a python terminal there and run the import statement.