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.

Overflowerror with Python 3.7 on Windows

See original GitHub issue

The add_hotkey function doesn’t work on Windows with Python 3.7 (64-bit):

import keyboard, time

keyboard.add_hotkey('a', print)

time.sleep(5)

The traceback:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python37\lib\threading.py", line 917, in _bootstrap_inner
    self.run()
  File "C:\Python37\lib\threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python37\lib\site-packages\keyboard\__init__.py", line 292, in listen
    _os_keyboard.listen(self.direct_callback)
  File "C:\Python37\lib\site-packages\keyboard\_winkeyboard.py", line 560, in listen
    prepare_intercept(callback)
  File "C:\Python37\lib\site-packages\keyboard\_winkeyboard.py", line 553, in prepare_intercept
    keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, GetModuleHandleW(NULL), NULL)
ctypes.ArgumentError: argument 3: <class 'OverflowError'>: int too long to convert

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
j-lagcommented, Feb 5, 2019

I m also having this issue with python3.7 and windows 10. Quick and dirty fix: removing the call to GetModuleHandleW seems to work for my simple use case.

_winkeyboard.py line 553:
SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, GetModuleHandleW(NULL), NULL) -> SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, NULL, NULL)
7reactions
Farm-Artcommented, Jul 5, 2018

Not just the hotkeys, any attempt to create a hook fails.

Read more comments on GitHub >

github_iconTop Results From Across the Web

datetime.datetime.now() raises an OverflowError for date after ...
> I get this error when starting the interpreter in Windows subsystem for Linux (WSL). This bug is currently closed, please open a...
Read more >
Python Pywin32 - ReadEventLog OverflowERROR
I'm using Python 3.7 on Windows (64 bit). Thanks in advance! python · pywin32 · Share.
Read more >
How to install python 3.7 on windows 10 PC , The non ...
Ready to start learning python? You may think installing python 3.7 is the right step, I recommend starting with python 2.7 and upgrade...
Read more >
Install Python on Windows | Learn 7 Useful Steps to ... - eduCBA
This dashboard is also called as the python setup pop up window, and a snap of the same is pasted below; this snap...
Read more >
SciPy 1.8.0 Release Notes — SciPy v1.9.3 Manual
This release requires Python 3.8+ and NumPy 1.17.3 or greater. ... It is currently default-off due to potential issues on Windows that we...
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