kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.53k stars 114 forks source link

Segmentation fault on Apple M1 #113

Closed elammertsma closed 2 years ago

elammertsma commented 3 years ago

Hey! This library works great on my Windows PC and was extremely easy to implement and use. Thank you!

Unfortunately, I'm running into issues getting my project running on my new Mac, and it seems to hang on import of gkeepapi. I'm getting a segmentation fault:

zsh: segmentation fault /opt/homebrew/bin/python3

I installed gkeepapi through pip3 and the project code runs if I comment out the import of gkeepapi.

From looking this up online, it seems to be an issue with M1 hardware, more commonly experienced by people trying to use numpy or scipy. They have success compiling these libraries locally, but I don't see that as an option here and wouldn't know where to start. Do you have any pointers?

Thanks! (I apologize if I'm supplying insufficient information. I'm still fairly new to Python and am not a pro Mac user.)

Operating system: macOS Big Sur v11.4 on a 2020 Macbook Pro, 13 inch, on the Apple M1 chip Python version: 3.9.6 64bit

kiwiz commented 3 years ago

Looks like this is related to https://github.com/Legrandin/pycryptodome/issues/506 (gkeepapi uses gpsoauth which includes this dependency https://github.com/simon-weber/gpsoauth/blob/master/pyproject.toml#L25). You might be able to work around this by using a different Python version?

elammertsma commented 3 years ago

Thanks for the tip! Moving to Python 3.8.2 solved the segmentation fault on my Mac but it seems like there are more issues with gpsoauth on Mac. Version 4.3 gives me this error: AttributeError: attribute 'post_handshake_auth' of '_ssl._SSLContext' objects is not writable

Downgrading to version 4.2 fixes that but then I get the following error: File "/Users/eric/Library/Python/3.8/lib/python/site-packages/gkeepapi/__init__.py", line 695, in login ret = auth.login(username, password, device_id) File "/Users/eric/Library/Python/3.8/lib/python/site-packages/gkeepapi/__init__.py", line 59, in login raise exception.LoginException( gkeepapi.exception.LoginException: ('BadAuthentication', None)

I've checked that I'm passing in the correct credentials, so I'm not sure where the authentication process could be going wrong.

Meanwhile, the exact same code (without messing with gpsoauth versions) works great on my Windows machine and in Google Cloud as a Cloud Function running Python 3.9. Very weird that it's so specifically an issue on my Mac.

kiwiz commented 3 years ago

The BadAuthentication issue is probably related to https://github.com/kiwiz/gkeepapi/issues/81. Rather than gpsoauth you might get some results with changing the version of pycryptodome (but this might break your env in other unexpected ways).

Your best bet might be to run your code in a Docker container for now. :thinking: