解决 ImportError: cannot import name ‘PyKeyboard‘ from ‘pykeyboard
1,问题概述
from pykeyboard import PyKeyboard,运行时出现如下错误:
ImportError: cannot import name ‘PyKeyboard‘ from ‘pykeyboard‘
2,解决方法
进入C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\pykeyboard\__init__.py
在文件后面追加如下代码
from .inline_keyboard import InlineKeyboard from .inline_pagination_keyboard import InlinePaginationKeyboard from .reply_keyboard import ReplyKeyboard import sys if sys.platform.startswith('java'): from .java_ import PyKeyboard elif sys.platform == 'darwin': from .mac import PyKeyboard, PyKeyboardEvent elif sys.platform == 'win32': from .windows import PyKeyboard, PyKeyboardEvent else: from .x11 import PyKeyboard, PyKeyboardEvent