我有一个问题,我找不到任何帮助。这个想法是我不能导入pynput。我做了pip安装,这就是它显示的内容:
> Traceback (most recent call last):
File "sb.py", line 1, in <module>
from pynput.keyboard import Key, Controller
ImportError: No module named pynput.keyboard
我再次尝试pip install pynput并显示
要求已经满足
这是代码,我不知道它是否有帮助,但你去了:
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.."
提前致谢
你是如何运行该文件的?当你做python3 nameofyourprogram.py时,你应该使用pip3 install pynput
上次我有这个问题,那是因为我已经使用pip为给定版本的python安装了模块(比方说2.7),但我使用python 3.6运行我的脚本。尝试检查版本。