[英]ModuleNotFoundError when importing ‘keyboard’ in Python
这是几句话的故事。 彩票游戏。 导入键盘。 Linux 根。 模块未找到错误。 为什么在导入的“键盘”上有 ModuleNotFoundError?
这是导入的代码片段以及我使用它的目的。
import keyboard
if userNums == winningNums:
print(“\nCongratulations! You won the jackpot!”)
print(“Press M to return to the menu.”)
if keyboard.is_pressed(“m”):
printMenu()
else:
print(“Please press M to return to the menu!”)
(已编辑)
经过小小的搜索,我发现了同样的问题,我发现问题已通过下一个安装说明解决
python -m pip install keyboard
安装后关闭 ide 然后打开它,应该完成。
看起来您有多个 Python 环境。 并且您选择了没有安装keyboard
模块的 python 解释器。
您能否通过pip show keyboard
检查您在哪里安装了keyboard
模块? 您从 VSCode 的左下角选择了哪个 python 解释器?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.