question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: module 'keyboard._darwinkeyboard' has no attribute 'type_unicode'

See original GitHub issue

Hello, I am testing your “write.py” example on OSX Sierra 10.12.6. I tested this using the native python 2.7.10 and brew install of python 3 at 3.6.2. Used pip to install keyboard once in both python environments. Both had identical errors listed below.

The program actually works, but then crashes with the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/keyboard/__init__.py", line 570, in write
    scan_code, modifiers = _os_keyboard.map_char(letter)
  File "/usr/local/lib/python3.6/site-packages/keyboard/_darwinkeyboard.py", line 390, in map_char
    return key_controller.map_char(character)
  File "/usr/local/lib/python3.6/site-packages/keyboard/_darwinkeyboard.py", line 305, in map_char
    return self.key_map.character_to_vk(character)
  File "/usr/local/lib/python3.6/site-packages/keyboard/_darwinkeyboard.py", line 153, in character_to_vk
    raise ValueError("Unrecognized character: {}".format(character))
ValueError: Unrecognized character: enter

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "write.py", line 14, in <module>
    keyboard.write(line)
  File "/usr/local/lib/python3.6/site-packages/keyboard/__init__.py", line 584, in write
    _os_keyboard.type_unicode(letter)
AttributeError: module 'keyboard._darwinkeyboard' has no attribute 'type_unicode'

I cannot tell if this is a configuration, dependency or other problem. But it is an issue with one of the standard examples.

Thanks for your Open Source contributions.

Regards, -FT

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bopprehcommented, Oct 29, 2017

Hi @antontarasenko

I never had a Mac, so imagine my surprise when I learned that the “backspace” key in a Mac is named “delete”, and the “delete” is “forward delete”. The library seems to be going by that, so the “backspace” key was missing.

I changed the names around to the more cross-platform way, which I understand may break some things, but is a choice that must be named. Any opinion on this, @glitchassassin ?

I also added a bunch more key codes. Again, I can’t test any of this, so @antontarasenko , could you test the latest master version, ccfdc1c?

1reaction
antontarasenkocommented, Oct 29, 2017

@boppreh

Hi! Another happy user of your package has this error.

I’m doing keyboard.add_abbreviation('email', 'my.long.email@example.com') like this:

import sys
sys.path.insert(0, '__PATH_TO_LATEST_KEYBOARD_VERSION__')
import keyboard

if __name__ == '__main__':
    keyboard.add_abbreviation('email', 'my.long.email@example.com')
    keyboard.wait()

Then I run this file, type email<space> in a terminal or text editor, and the script returns:

...
ValueError: Unrecognized character: backspace
...
AttributeError: module 'keyboard._darwinkeyboard' has no attribute 'type_unicode'

I’m using the fixed version as in https://github.com/boppreh/keyboard/commit/f740496780ea7f1e3ebdf422db99a328b5bbea34

Details:

  • MacOS X 10.11.3.
  • Quartz installed with pip3 install pyobjc-core; pip3 install pyobjc-framework-Quartz not pip3 install quartz (the latter gives the requirements.txt error)
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - (AttributeError) installation problem with keyboard
I am having a issue when I try to use the keyboard module. My code is: import ...
Read more >
keyboard.is_pressed attribute error - Python Forum
Hello all. I'm totally new to python and try to walk before I can crawl. The intention of the below code is to...
Read more >
Handling the keyboard — pynput 1.7.6 documentation
from pynput import keyboard def on_press(key): try: print('alphanumeric key {0} pressed'.format( key.char)) except AttributeError: print('special key {0} ...
Read more >
Can't use the new keyboard component (from Psychtoolbox)
I created a basic Stroop experiment to check if everything was working properly and got this error message: WARNING Import Error: No module...
Read more >
keyboard - PyPI
Works with Windows and Linux (requires sudo), with experimental OS X support (thanks @glitchassassin!). Pure Python, no C modules to be compiled.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found