ModuleNotFoundError: No module named 'pynput.Keyboard'

ModuleNotFoundError: No module named 'pynput.Keyboard'

我无法导入 pynput 我安装了 pip,这是错误:

from pynput.Keyboard import Key
ModuleNotFoundError: No module named 'pynput.Keyboard'

当我尝试再次下载它时说:要求已经满足

我正在使用 python 3.7

这是代码,如果有帮助的话:

from pynput.Keyboard import Key
from pynput.Keyboard import Controller


KeyBoard = Controller()
KeyBoard.press('a')
KeyBoard.release('a')

键盘是小写的。所以你的代码应该是:

from pynput.keyboard import Key
from pynput.keyboard import Controller

KeyBoard = Controller()
KeyBoard.press('a')
KeyBoard.release('a')