I. Yoon
I. Yoon

Reputation: 41

import keyboard for python error

So i downloaded the keyboard module for python 2.7 using

pip install keyboard.

After installing i tried to import it as such

import keyboard as keyboard

however it gives me this error:

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

my only guess is that i dont have one of these files or i need another dependancy for keyboard. Any help would be much appreciated

Upvotes: 4

Views: 5486

Answers (1)

ivan_pozdeev
ivan_pozdeev

Reputation: 35998

This is a bug in Python that was caused in the 2.7 release line by https://bugs.python.org/issue27330 and fixed in https://bugs.python.org/issue29082 . It exists in 2.7.13 and is fixed in 2.7.14.

keyboard triggers this bug by using from __future__ import unicode_literals in keyboard._winkeyboard.

Upvotes: 4

Related Questions