Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h3-py doesn't work with native python (Arm-64 architecture) on Apple M1 #204

Closed
lixun910 opened this issue Nov 4, 2021 · 4 comments · Fixed by #221
Closed

h3-py doesn't work with native python (Arm-64 architecture) on Apple M1 #204

lixun910 opened this issue Nov 4, 2021 · 4 comments · Fixed by #221

Comments

@lixun910
Copy link

lixun910 commented Nov 4, 2021

This is just a log here since Github doesn't support action on Apple M1 yet. Maybe do a manual build for M1 users?

>>> import platform
>>> platform.processor()
'arm'
>>> import h3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/__init__.py", line 3, in <module>
    from .api.basic_str import *
  File "/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/api/__init__.py", line 3, in <module>
    from . import basic_int
  File "/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/api/basic_int.py", line 16, in <module>
    from ._api_template import _api_functions
  File "/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/api/_api_template.py", line 46, in <module>
    from .. import _cy
  File "/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/_cy/__init__.py", line 16, in <module>
    from .cells import (
ImportError: dlopen(/Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/_cy/cells.cpython-38-darwin.so, 2): no suitable image found.  Did find:
        /Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/_cy/cells.cpython-38-darwin.so: mach-o, but wrong architecture
        /Users/xun/PycharmProjects/pythonProject/venv_h3py/lib/python3.8/site-packages/h3/_cy/cells.cpython-38-darwin.so: mach-o, but wrong architecture
@kylebarron
Copy link
Contributor

kylebarron commented Nov 4, 2021

That looks really weird. Specifically that implies that when you installed h3, you received an x86-64 wheel. IMO that looks more like a pip error than an h3 error. Can you show the log from pip install h3? (Can you also try upgrading pip with pip install -U pip and then trying again?) I would've expected pip to build from source and not match the x86-64 image.

Also ref: #190. It's true that Github Actions doesn't support M1 execution environments, but you can still cross-compile a wheel for M1 using cibuildwheel. In another of my projects it consisted of "just" adding an CIBW_ARCHS_MACOS environment variable, but h3 has a more complicated setup because it needs to compile with h3.

@lixun910
Copy link
Author

lixun910 commented Nov 4, 2021

I am using native arm64 python 3.8, so it should expect the xxx.arm64.whl when do pip install. I can't find one on the pypi site: https://pypi.org/project/h3/#files

Since I am working on an M1 machine, I think I can try to create an arm64 wheel. Will keep you updated :)

@kylebarron
Copy link
Contributor

I think you should be able to follow the development steps to build a wheel yourself. https:/uber/h3-py/blob/master/dev_notes.md

Should be something like make init && python setup.py bdist_wheel off the top of my mind.

@mattigrthr
Copy link

I had a similar problem on an M1 with macOS 12.2.1. This was the error message I got:

(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/cells.cpython-38-darwin.so' (no such file), '/usr/lib/cells.cpython-38-darwin.so' (no such file)

I got it running by installing Python 3.10.2 through pyenv and using pip 22.0.3 with --no-cache-dir when installing the package. Hope this might help somebody stumbling upon this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants