nmslib: pybind11.h not found when installing using pip

I’m trying to install python bindings on Ubuntu 16.04 machine:

$ pip3 install pybind11 nmslib
Collecting nmslib
  Using cached https://files.pythonhosted.org/packages/de/eb/28b2060bb1750426c5618e3ad6ce830ac3cfd56cb3eccfb799e52d6064db/nmslib-1.7.2.tar.gz
Requirement already satisfied: pybind11>=2.0 in /homes/alexandrov/.virtualenvs/pytorch/lib/python3.5/site-packages (from nmslib) (2.2.2)
Requirement already satisfied: numpy in /homes/alexandrov/.virtualenvs/pytorch/lib/python3.5/site-packages (from nmslib) (1.14.2)
Building wheels for collected packages: nmslib
  Running setup.py bdist_wheel for nmslib ... error
  Complete output from command /homes/alexandrov/.virtualenvs/pytorch/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-0y71oxa4/nmslib/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-916r1rr9 --python-tag cp35:
  running bdist_wheel
  running build
  running build_ext
  creating tmp
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/homes/alexandrov/.virtualenvs/pytorch/include/python3.5m -c /tmp/tmpwekdswov.cpp -o tmp/tmpwekdswov.o -std=c++14
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/homes/alexandrov/.virtualenvs/pytorch/include/python3.5m -c /tmp/tmpyyphh022.cpp -o tmp/tmpyyphh022.o -fvisibility=hidden
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  building 'nmslib' extension
  creating build
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/nmslib
  creating build/temp.linux-x86_64-3.5/nmslib/similarity_search
  creating build/temp.linux-x86_64-3.5/nmslib/similarity_search/src
  creating build/temp.linux-x86_64-3.5/nmslib/similarity_search/src/method
  creating build/temp.linux-x86_64-3.5/nmslib/similarity_search/src/space
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./nmslib/similarity_search/include -Iinclude -Iinclude -I/homes/alexandrov/.virtualenvs/pytorch/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/homes/alexandrov/.virtualenvs/pytorch/include/python3.5m -c nmslib.cc -o build/temp.linux-x86_64-3.5/nmslib.o -O3 -march=native -fopenmp -DVERSION_INFO="1.7.2" -std=c++14 -fvisibility=hidden
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  nmslib.cc:16:31: fatal error: pybind11/pybind11.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Clearly, pybind11 headers were not installed on my machine. This library is not packaged for apt-get (at least not for Ubuntu 16.04), so I needed to manually install from source.

Would be nice if nmslib install script took care of this.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (15 by maintainers)

Most upvoted comments

@taketwo as a short term fix, trying going ‘pip install pip==9.0.3’ and then installing nmslib - longer term I think we will have to wait for a patched version of pybind11

@searchivarius I’ll see if I can replicate this with the install_requires being ignored

hmm - so there might be two separate problems there (not installing pybind11 as part of the install, and not getting the correct path from pybind11 once it is installed).

I think I’ve managed to replicate the problem here. It seems like the issue is with pybind11 and pip10 . With that combination the ‘pybind11.get_include’ returns just ‘include’ instead of the fully qualified path:


In [1]: import pybind11

In [2]: pybind11.get_include()
Out[2]: 'include'

In [3]: import pip

In [4]: pip.__version__
Out[4]: '10.0.1'

versus


In [1]: import pybind11

In [2]: pybind11.get_include()
Out[2]: '/Users/ben/anaconda3/include/python3.6m'

In [3]: import pip

In [4]: pip.__version__
Out[4]: '9.0.3'