ImportError: No module named pynput.keyboard

こ雲淡風輕ζ 提交于 2020-11-30 00:10:05

问题


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


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/55242218/importerror-no-module-named-pynput-keyboard

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!