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.

StopIteration during keyboard.write

See original GitHub issue

On Fedora 28 with Python 3.6.6 I get the following problem:

>>> text = "TESTAA"
>>> keyboard.write(text)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/some/path/venv/lib/python3.6/site-packages/keyboard/__init__.py", line 852, in write
    scan_code, modifiers = next(iter(entries))
StopIteration
>>> TEST

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:15

github_iconTop GitHub Comments

3reactions
aliDaRoostercommented, Oct 28, 2018

Hi! I have exactly the same problem on Ubuntu 18.04, however I can use keyboard from pynput module for the same purposes, here is an example: from pynput.keyboard import Controller keyboard=Controller() keyboard.type('TESTAA') For doing so you need to download the pynput module, which can be downloaded from the terminal via pip with: pip install pynput There is also a complete tutorial about simulating keypresses with pynput: https://nitratine.net/simulate-keypresses-in-python/

2reactions
thecircleoflifefreecommented, Jul 1, 2020

Same issue on Centos 7 machine… script is simple

import keyboard keyboard.write(“Python Programming is kinda cool I should say!”, delay=0.3) keyboard.send(‘windows+l’)

Steps to repro:

$ sudo python3 test_keyboard.py Traceback (most recent call last): File “test_keyboard.py”, line 3, in <module> keyboard.write(“Python Programming is kinda cool I should say!”, delay=0.3) File “/usr/local/lib/python3.6/site-packages/keyboard/init.py”, line 854, in write scan_code, modifiers = next(iter(entries)) StopIteration

I’ve done research in SO but nothing… this appears the only place and the issue is Open.

If someone knows an alternative to the “keyboard” module that would be fantastic!

I am aware that something like this could be used(windows example):

import os os.system(‘rundll32.exe user32.dll,LockWorkStation’)

However something more high level that can work on most machines would be best.

Read more comments on GitHub >

github_iconTop Results From Across the Web

StopIteration error in python - Stack Overflow
StopIteration is raised when generator is exhausted and has no more values, it's totaly ok to get one. But you need to handle...
Read more >
Developers - StopIteration during keyboard.write - - Bountysource
On Fedora 28 with Python 3.6.6 I get the following problem: >>> text = "TESTAA" >>> keyboard.write(text) Traceback (most recent call last): File...
Read more >
Issue 31156: Stopiteration terminates while-loop - Python tracker
msg299982 ‑ (view) Author: Günter Rote (Günter Rote) Date: 2017‑08‑09 09:49 msg300005 ‑ (view) Author: R. David Murray (r.david.murray) * Date: 2017‑08‑09 13:37 msg300011 ‑...
Read more >
Behaviors — Kivy 2.2.0.dev0 documentation
(internal) Used by the controller to get the node at the position indicated by key. The key can be keyboard inputs, e.g. pageup,...
Read more >
Complete Guide to Python KeyboardInterrupt - eduCBA
There is no such specific syntax of KeyboardInterrupt exception in Python, it is handled in the normal try and except block inside the...
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