boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.8k stars 433 forks source link

Trouble Importing module on Mac OS Monterey #521

Open Ashrit-Yarava opened 2 years ago

Ashrit-Yarava commented 2 years ago

Importing the module fails. error.txt

BytePhoenixCoding commented 2 years ago

Known issue, I get the same, it may be because of the M1 chip

Vespertilo commented 2 years ago

Same issue here on Mac OS Big Sur. I have an M1 chip though which seems to be the source of the cause.

alaninnovates commented 2 years ago

Same here, Mac OS Monterey (M1 chip)

However, for me, I get a segfault when importing the library:

python
Python 3.9.10 (main, Jan 15 2022, 11:40:53) 
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyboard
zsh: segmentation fault  python
rasoolmohammedy commented 2 years ago

I too receive the segmentation fault error. Any alternatives or ETA is known?

PythonCrash
ghost commented 2 years ago

same here, segmentation fault error whenever I try to run a program with import keyboard

boppreh commented 2 years ago

It uses ctypes, so it needs an update before supporting an ARM-based CPU like M1.

Unfortunately I don't have a Mac to develop on, so I rely 100% on community contributions for Mac support :(

rasoolmohammedy commented 2 years ago

Hi @boppreh, I have Mac M1 without Rosetta i.e. ARM64 architecture type. Can you please assist me on how and where to make the changes?

boppreh commented 2 years ago

@rasoolmohammedy It's somewhere in https://github.com/boppreh/keyboard/blob/master/keyboard/_darwinkeyboard.py , though where exactly needs more testing.

Some places that could be:

It'd suggest it running it with pydb step by step during initialization. That should tell you which of the above are causing problems.

ghost commented 2 years ago

@Ashrit-Yarava @rasoolmohammedy from python 3.10.2 onwards universal binaries are provided, so that if you are facing an issue with importing modules that crash on segmentation fault you can simply run your program likewise python3-intel64 yourprogram.py I tried this with a program that imports keyboard and I faced no problem at all.

from Python 3.10.2 changelog:

" Provide “python3.x-intel64” executable to allow reliably forcing macOS universal2 framework builds to run under Rosetta 2 Intel-64 emulation on Apple Silicon Macs. This can be useful for testing or when universal2 wheels are not yet available. "

rasoolmohammedy commented 2 years ago

Hi @4sito ,

Thank you for your comment, the problem what we have right now is, we don't have Rosetta emulator installed on Mac M1 hence we will not be able to run python3-intel64 :(

ghost commented 2 years ago

@rasoolmohammedy, sorry but Rosetta should automatically install anytime you try to run an x86 application, I had my M1 Mac for more than a year now, but IIRC there shouldn't be any problem installing Rosetta, as it is an automatic process, other than that unfortuntely I don't know how to help you furthermore

rasoolmohammedy commented 2 years ago

Hi @4sito,

Thank you for your comment. In our case, it is mandatory to run our automation suite without Rosetta. that is our precondition. With rosetta this module works absolutely fine till date.

ghost commented 2 years ago

@rasoolmohammedy oh ok, didn't knew that, unfortunately I can't help you if that's the problem