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.

Exception with Python 3.6.5 64 bit and pyinstaller

See original GitHub issue

When using keyboard with python 3.6.5 64 bit and running inside of pyinstaller, this error is returned:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "threading.py", line 916, in _bootstrap_inner
  File "threading.py", line 864, in run
  File "site-packages\keyboard\__init__.py", line 296, in listen
  File "site-packages\keyboard\_winkeyboard.py", line 562, in listen
  File "site-packages\keyboard\_winkeyboard.py", line 555, in prepare_intercept
ctypes.ArgumentError: argument 3: <class 'OverflowError'>: int too long to convert

I found a couple of other issues on other projects describing the same issue: https://github.com/rene-aguirre/pywinusb/issues/30 https://github.com/jaraco/jaraco.windows/issues/7 https://stackoverflow.com/questions/44163105/python-3-5-1-amd64-ctypes-argumenterror-argument-1-class-overflowerror https://bitbucket.org/pyglet/pyglet/issues/147/ctypesargumenterror-argument-4-int-too

Not sure exactly how to solve this for keyboard, but I am using 0.13.1. This error does not appear for me when I force using 32 bit Python in pyinstaller. I also only see the error inside of pyinstaller, not when just running a project normally with Python 3.6.5 64 bit.

This is all being done on Windows 10.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

29reactions
taylorsmurphycommented, May 17, 2018

I figured out the easy workaround finally, @GbeTech this should work for you too.

in keyboard\_winkeyboard.py line 555 replace keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, GetModuleHandleW(None), None) with keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, keyboard_callback, ctypes.c_ulonglong(GetModuleHandleW(None)), None)

GetModuleHandleW needs to be wrapped in ctypes.c_ulonglong or you get the overflow error. If the problem happens in any other modules you come across, the fix should be similar.

I’m not sure if this is the right way to do it @boppreh, (perhaps it should be specified earlier, or conditional on 32 vs 64 bit, but it works for my system).

5reactions
bopprehcommented, Apr 8, 2018

Thank you for the in-depth report, I’m working on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Created exe from .py using pyinstaller has issues ...
The issue is when I run the exe. Python 3.6.5 Pyinstaller 3.3.1 Build platform : Win 8.1 64bit Running platform Win 7 64bit...
Read more >
pyinstaller 3.6 - PyPI
PyInstaller bundles a Python application and all its dependencies into a single package. ... Update PyQt5 to package 64-bit SSL support DLLs. (#4321)....
Read more >
Changelog for PyInstaller — PyInstaller 5.7.0 documentation
Fix potential duplication of python extension modules in onefile ... If built on an ARM machine, --target-arch=64bit-arm is the default.
Read more >
PyInstaller Documentation - Read the Docs
A quick summary of the GPL license exceptions: ... bootloader, and 32-bit/64-bit Python installers are still available from python.org for (some) versions ...
Read more >
Compilation error between Pyzo and PyInstaller version 4.2
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) on Windows (64 bits). This is the Pyzo interpreter with integrated event loop ...
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