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

cann't install on MAC M1 #577

Open
ArlanCooper opened this issue Oct 11, 2021 · 6 comments
Open

cann't install on MAC M1 #577

ArlanCooper opened this issue Oct 11, 2021 · 6 comments

Comments

@ArlanCooper
Copy link

the error message like this:
Using legacy 'setup.py install' for annoy, since package 'wheel' is not installed.
Installing collected packages: annoy
Running setup.py install for annoy ... error
ERROR: Command errored out with exit status 1:
command: /Users/cooper/PycharmProjects/faq/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-install-gf4q13ts/annoy_789593428b7643f98169824423d770ff/setup.py'"'"'; file='"'"'/private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-install-gf4q13ts/annoy_789593428b7643f98169824423d770ff/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-record-dcdyq3od/install-record.txt --single-version-externally-managed --compile --install-headers /Users/cooper/PycharmProjects/faq/venv/include/site/python3.8/annoy
cwd: /private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-install-gf4q13ts/annoy_789593428b7643f98169824423d770ff/
Complete output (15 lines):
WARNING: The wheel package is not available.
running install
running build
running build_py
creating build
creating build/lib.macosx-10.14-x86_64-3.8
creating build/lib.macosx-10.14-x86_64-3.8/annoy
copying annoy/init.py -> build/lib.macosx-10.14-x86_64-3.8/annoy
running build_ext
building 'annoy.annoylib' extension
creating build/temp.macosx-10.14-x86_64-3.8
creating build/temp.macosx-10.14-x86_64-3.8/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Users/cooper/PycharmProjects/faq/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/annoymodule.cc -o build/temp.macosx-10.14-x86_64-3.8/src/annoymodule.o -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math -std=c++11 -mmacosx-version-min=10.9
clang: error: the clang compiler does not support '-march=native'
error: command 'clang' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/cooper/PycharmProjects/faq/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-install-gf4q13ts/annoy_789593428b7643f98169824423d770ff/setup.py'"'"'; file='"'"'/private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-install-gf4q13ts/annoy_789593428b7643f98169824423d770ff/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/np/pjvnrzpj65q2p4gv1pfh8nqc0000gn/T/pip-record-dcdyq3od/install-record.txt --single-version-externally-managed --compile --install-headers /Users/cooper/PycharmProjects/faq/venv/include/site/python3.8/annoy Check the logs for full command output.

my computer is MAC M1, how to install,thanks

@yauhenAI2
Copy link

yauhenAI2 commented Dec 9, 2021

Hi, I've installed annoy on M1 successfully following the steps:

  1. Create virtual env and activate it (optional)
  2. Install with pip:
(annoy) user@local Desktop % pip3 install annoy      
Collecting annoy
  Downloading annoy-1.17.0.tar.gz (646 kB)
     |████████████████████████████████| 646 kB 443 kB/s            
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: annoy
  Building wheel for annoy (setup.py) ... done
  Created wheel for annoy: filename=annoy-1.17.0-cp39-cp39-macosx_12_0_arm64.whl size=55704 sha256=44c6d6a0f519ef122e04ca6db077a2d9c78402fd5f11bbdfbd77f30f785fa20c
  Stored in directory: /Users/user/Library/Caches/pip/wheels/71/d0/7a/354f18c65441aacd7e2806fe7e0d2f827da30e89683eb788bb
Successfully built annoy
Installing collected packages: annoy
Successfully installed annoy-1.17.0
WARNING: You are using pip version 21.3; however, version 21.3.1 is available.
You should consider upgrading via the '/Users/user/Desktop/annoy/bin/python -m pip install --upgrade pip' command.
  1. Run a test example to confirm it works (optional):
(annoy) user@local Desktop % python3
Python 3.9.9 (main, Nov 21 2021, 03:16:13) 
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from annoy import AnnoyIndex
>>> import random
>>> 
>>> f = 40
>>> t = AnnoyIndex(f, 'angular')  # Length of item vector that will be indexed
>>> for i in range(1000):
...     v = [random.gauss(0, 1) for z in range(f)]
...     t.add_item(i, v)
... 
>>> t.build(10) # 10 trees
True
>>> t.save('test.ann')
True
>>> 
>>> # ...
>>> 
>>> u = AnnoyIndex(f, 'angular')
>>> u.load('test.ann') # super fast, will just mmap the file
True
>>> print(u.get_nns_by_item(0, 1000)) # will find the 1000 nearest neighbors
[0, 138, 99, ... 976,...957]

@excited-tiger
Copy link

Hi, I've installed annoy on M1 successfully following the steps:

use python 3.9

@tidalmelon
Copy link

would build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')

@amayuelas
Copy link

I am getting the same error on a Mac M1, Python 3.9.10

clang-13: error: the clang compiler does not support '-march=native'

@amayuelas
Copy link

As mentioned in #567

To solve this issue you

export CC=/usr/bin/clang ; 
export CXX=/usr/bin/clang++

Then install annoy: pip install annoy

@simongcc
Copy link

simongcc commented May 6, 2024

@amayuelas Thanks for this clue. So that when I check with clang command. Found out the XCode user agreeement is not yet checked. The compilation failed with similar error. The reason is very unobvious. After checking the agreement, it works as expected.

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

6 participants