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

Issues Installing pynanoflann on Apple Silicon #39

Open
corinwagen opened this issue Dec 18, 2024 · 0 comments
Open

Issues Installing pynanoflann on Apple Silicon #39

corinwagen opened this issue Dec 18, 2024 · 0 comments

Comments

@corinwagen
Copy link

Hey folks, I encountered some difficulties getting ORB models to run on my 2023 Macbook Pro (Apple Silicon, M3 Pro). I figured I'd document the steps I took, since others might have these same issues and it might be worth making a note in README.md.

Problem

Running:

$ pip install "pynanoflann@git+https://github.com/dwastberg/pynanoflann#egg=af434039ae14bedcbb838a7808924d6689274168",
$ python
>>> import pynanoflann
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/__init__.py", line 1, in <module>
    from .nanoflann import KDTree, batched_kneighbors
  File "/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/nanoflann.py", line 6, in <module>
    from . import nanoflann_ext
ImportError: dlopen(/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/nanoflann_ext.cpython-312-darwin.so, 0x0002): tried: '/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/nanoflann_ext.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/nanoflann_ext.cpython-312-darwin.so' (no such file), '/Users/cwagen/micromamba/envs/nnp/lib/python3.12/site-packages/pynanoflann/nanoflann_ext.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

My Solution

(1) Clone pynanoflann

$ git clone https://github.com/dwastberg/pynanoflann.git
$ cd pynanoflann

(2) Modify their CMakeLists.txt file and add the following lines (these became lines 10–13 in the new file):

if(APPLE)
    # Ensure compatibility with ARM64 architecture on macOS
    set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architecture" FORCE)
endif()

(3) Install the modified version into whatever environment:

$ pip install .
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

No branches or pull requests

1 participant