导入键盘的python错误

时间:2018-07-08 12:28:28

标签: python python-2.7

所以我使用

下载了python 2.7的键盘模块

pip install keyboard.

安装后,我尝试将其导入为

import keyboard as keyboard

但是它给了我这个错误:

File "C:\Python27\lib\site-packages\keyboard\__init__.py", line 120, in <module>
    from. import _winkeyboard as _os_keyboard
  File "C:\Python27\lib\site-packages\keyboard\_winkeyboard.py", line 37, in <module>
    kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
  File "C:\Python27\lib\ctypes\__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be string, not unicode

我唯一的猜测是我没有这些文件之一,或者我需要键盘的另一个依赖。任何帮助将不胜感激

1 个答案:

答案 0 :(得分:3)

这是Python中的一个错误,该错误由https://bugs.python.org/issue27330在2.7版本中引起,并已在https://bugs.python.org/issue29082中修复。 exists in 2.7.13is fixed in 2.7.14

keyboard触发此错误by using from __future__ import unicode_literals in keyboard._winkeyboard