Viorel Andrei Chis
Viorel Andrei Chis

Reputation: 147

ImportError: No module named pynput.keyboard

I have a problem and I can't find anything to help.The idea is that I can't import pynput. I did the pip install and this is what it shows:

> Traceback (most recent call last):
  File "sb.py", line 1, in <module>
    from pynput.keyboard import Key, Controller
  ImportError: No module named pynput.keyboard

I tried again pip install pynput and it shows

Requirement already satisfied

Here is the code, i don't know if it helps but there you go:

from pynput.keyboard import Key, Controller
def game():
    keyboard = Controller()
    if key.press():
        s = Sound()
        s.read("Cymatics - Guitar Chord Loop 2 - 128 BPM Dmaj")
        s.play()

print "Welcome to soundboard"
print "You will see a list of sound names, just write the name of it"
print "If you want to stop it type stop"
print "Type start"

start = input()
if start.lower() == "start":
    while True:
        game()
else:
    print "Ups, try again.."

Thanks in advance

Upvotes: 1

Views: 11937

Answers (2)

willy1994
willy1994

Reputation: 76

How are you running the file? When you do python3 nameofyourprogram.py you should use pip3 install pynput

Upvotes: 2

Arkangus
Arkangus

Reputation: 116

Last time I had this issue, it was because I had installed the module using pip for a given version of python (lets say 2.7), but I was running my script using python 3.6. Try to check the versions.

Upvotes: 2

Related Questions