添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Thank so you, that was the problem.I am a beginner and I didn't knew that, I used pip3 to install it.Thanks again! – Viorel Andrei Chis Mar 19, 2019 at 13:41

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.

If you did pip install pynput, you can check on which python it is installing it using pip --version. – Arkangus Mar 19, 2019 at 13:43

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.