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

ERROR: Failed building wheel for annoy #567

Open
garynanxu opened this issue Aug 11, 2021 · 11 comments
Open

ERROR: Failed building wheel for annoy #567

garynanxu opened this issue Aug 11, 2021 · 11 comments

Comments

@garynanxu
Copy link

garynanxu commented Aug 11, 2021

I tried to install Annoy by pip on Ubuntu 20.04.
I got an error message: failed building wheel for annoy.

ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"'; file='"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-0ie3nc4q
cwd: /tmp/pip-install-ljwa9_uc/annoy/
Complete output (17 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/annoy
copying annoy/init.py -> build/lib.linux-x86_64-3.8/annoy
running build_ext
building 'annoy.annoylib' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c src/annoymodule.cc -o build/temp.linux-x86_64-3.8/src/annoymodule.o -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math -DANNOYLIB_MULTITHREADED_BUILD -std=c++14
cc1plus: error: bad value (‘tigerlake’) for ‘-march=’ switch
cc1plus: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 native
cc1plus: error: bad value (‘tigerlake’) for ‘-mtune=’ switch
cc1plus: note: valid arguments to ‘-mtune=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm intel x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 generic native
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Failed building wheel for annoy
Running setup.py clean for annoy
Failed to build annoy
Installing collected packages: annoy
Running setup.py install for annoy ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"'; file='"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-6akexab_/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/annoy
cwd: /tmp/pip-install-ljwa9_uc/annoy/
Complete output (17 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/annoy
copying annoy/init.py -> build/lib.linux-x86_64-3.8/annoy
running build_ext
building 'annoy.annoylib' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.8 -c src/annoymodule.cc -o build/temp.linux-x86_64-3.8/src/annoymodule.o -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math -DANNOYLIB_MULTITHREADED_BUILD -std=c++14
cc1plus: error: bad value (‘tigerlake’) for ‘-march=’ switch
cc1plus: note: valid arguments to ‘-march=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 native
cc1plus: error: bad value (‘tigerlake’) for ‘-mtune=’ switch
cc1plus: note: valid arguments to ‘-mtune=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm intel x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 generic native
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"'; file='"'"'/tmp/pip-install-ljwa9_uc/annoy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-6akexab_/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/annoy Check the logs for full command output.

@mhulke
Copy link

mhulke commented Aug 24, 2021

I have the same error working in Terra within a python 3.7.10 environment. Annoy is used within another package, and whether I try to install the package or annoy independently, I keep getting the error 'Failed building wheel for annoy'.

@semskurto
Copy link

semskurto commented Oct 20, 2021

I think this situation is not related to 'annoy'. I ran into this issue with other libraries besides 'annoy'. I couldn't find an easy solution. (Often times my computer never booted while installing dependencies for solution) gcc/g++ may be related. Successful installation of 'annoy' with a fresh ubuntu 20.04 in virtual machine. But 'annoy' installation failed in my current Ubuntu 20.04. It will be difficult to reinstall the system :) I hope there is an easy way. @mhulke @garynanxu
#574
@erikbern

@ayunah
Copy link

ayunah commented Oct 29, 2021

I also have this issue on Ubuntu 20.04

`Collecting annoy
Using cached annoy-1.17.0.tar.gz (646 kB)
Building wheels for collected packages: annoy
Building wheel for annoy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/aiuna/dev/univie/knodle/knodle/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-od4pb2n1/annoy/setup.py'"'"'; file='"'"'/tmp/pip-install-od4pb2n1/annoy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-l72jbey2
cwd: /tmp/pip-install-od4pb2n1/annoy/
Complete output (17 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/annoy
copying annoy/init.py -> build/lib.linux-x86_64-3.8/annoy
running build_ext
building 'annoy.annoylib' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/aiuna/dev/univie/knodle/knodle/include -I/usr/include/python3.8 -c src/annoymodule.cc -o build/temp.linux-x86_64-3.8/src/annoymodule.o -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math -DANNOYLIB_MULTITHREADED_BUILD -std=c++14
src/annoymodule.cc:17:10: fatal error: Python.h: No such file or directory
17 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

ERROR: Failed building wheel for annoy
Running setup.py clean for annoy
Failed to build annoy
Installing collected packages: annoy
Running setup.py install for annoy ... error
ERROR: Command errored out with exit status 1:
command: /home/aiuna/dev/univie/knodle/knodle/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-od4pb2n1/annoy/setup.py'"'"'; file='"'"'/tmp/pip-install-od4pb2n1/annoy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /tmp/pip-record-xzjxwtqi/install-record.txt --single-version-externally-managed --compile --install-headers /home/aiuna/dev/univie/knodle/knodle/include/site/python3.8/annoy
cwd: /tmp/pip-install-od4pb2n1/annoy/
Complete output (17 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/annoy
copying annoy/init.py -> build/lib.linux-x86_64-3.8/annoy
running build_ext
building 'annoy.annoylib' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/aiuna/dev/univie/knodle/knodle/include -I/usr/include/python3.8 -c src/annoymodule.cc -o build/temp.linux-x86_64-3.8/src/annoymodule.o -D_CRT_SECURE_NO_WARNINGS -march=native -O3 -ffast-math -fno-associative-math -DANNOYLIB_MULTITHREADED_BUILD -std=c++14
src/annoymodule.cc:17:10: fatal error: Python.h: No such file or directory
17 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

`

` g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

`

@erikbern
Copy link
Collaborator

you probably have to install libpython or libpython-dev or something like that

@Einlar
Copy link

Einlar commented Nov 17, 2021

I had the same error, and solved it by upgrading gcc to v10, see here.

@YJ-AnthonyJo
Copy link

Solved with sudo apt-get install python3-dev. In python v2, use sudo apt-get install python-dev. I think this is not issue of annoy..

@rleaver152
Copy link

On a Mac, the solution is to:
export CC=/usr/bin/clang ; export CXX=/usr/bin/clang++

then pip install annoy

@muyifemi
Copy link

muyifemi commented May 3, 2023

On a Mac, the solution is to: export CC=/usr/bin/clang ; export CXX=/usr/bin/clang++

then pip install annoy

Please provide a solution guide for the windows OS

@Alex88xl
Copy link

Worked for me in Docker with python:3.11-slim

RUN apt-get update
&& apt-get install gcc -y
&& apt-get install g++ -y
&& apt-get install python3-dev -y
&& apt-get clean

It is important to have gcc and g++ installed

@thomaswengerter
Copy link

To resolve this issue for Centos 7:
Follow these instructions to install gcc-11
zylon-ai/private-gpt#644 (comment)

@mister-rao
Copy link

Worked for me in Docker with python:3.11-slim

RUN apt-get update && apt-get install gcc -y && apt-get install g++ -y && apt-get install python3-dev -y && apt-get clean

It is important to have gcc and g++ installed

Thanks a bunch!

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