annoy
annoy copied to clipboard
cann't install on MAC M1
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
Hi, I've installed annoy on M1 successfully following the steps:
- Create virtual env and activate it (optional)
- 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.
- 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]
Hi, I've installed annoy on M1 successfully following the steps:
use python 3.9
would build wheel with unsupported tag ('cp39', 'cp39', 'macosx_11_0_arm64')
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'
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