Skip to content

fatal error: pybind11/pybind11.h: No such file or directory #2

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

Closed
chadgh opened this issue May 19, 2016 · 28 comments
Closed

fatal error: pybind11/pybind11.h: No such file or directory #2

chadgh opened this issue May 19, 2016 · 28 comments
Assignees

Comments

@chadgh
Copy link

chadgh commented May 19, 2016

I tried following the example in the README and got the following error:

/tmp/tmp826vncgj/somecode.cpp:2:36: fatal error: pybind11/pybind11.h: No such file or directory
     #include <pybind11/pybind11.h>
@tbenthompson
Copy link
Owner

tbenthompson commented May 19, 2016

This is a problem with the installation. The pybind11 dependency isn't being found. It's hard to easily say what the problem is.

Some quick questions:

  1. Did you use pip to install?
  2. Operating system?
  3. Python version?
  4. Virtualenv? Conda environment? Anything like that?

Would you be willing to run these lines and then list the files in the folders that are output for me?

>>> import pybind11
>>> pybind11.get_include()
'/usr/local/include/python2.7'
>>> pybind11.get_include(True)
'/home/tbent/.local/include/python2.7'

@tbenthompson tbenthompson self-assigned this May 19, 2016
@chadgh
Copy link
Author

chadgh commented May 19, 2016

  1. Yes I used pip to install
  2. Arch Linux
  3. Python 3.5.1
  4. Virtualenv
>>> import pybind11
>>> pybind11.get_include()
'/home/chadgh/.pyenv/versions/3.5.1/include/python3.5m'
>>> pybind11.get_include(True)
'/home/chadgh/.local/include/python3.5m'

So maybe 3.5.1 is not supported?

@tbenthompson
Copy link
Owner

I use 3.5 for development, so that's not it.

Could you list the files in these folders?
/home/chadgh/.pyenv/versions/3.5.1/include/python3.5m/pybind11
/home/chadgh/.local/include/python3.5m/pybind11

@chadgh
Copy link
Author

chadgh commented May 19, 2016

Those paths don't exist. I have /home/chadgh/.pyenv/versions/3.5.1/include/python3.5m/ but no pybind11 in there. And I have up to /home/chadgh/.local/ but no include.

I also did a search (using the find command) at those levels and didn't find anything called pybind11.

@chadgh
Copy link
Author

chadgh commented May 19, 2016

In the virtualenvironment there is ./lib/python3.5/site-packages/pybind11 and ./include/site/python3.5/pybind11

@tbenthompson
Copy link
Owner

Want to list the files in ./include/site/python3.5/pybind11? I think pybind11 is getting confused about where it installed itself!

@chadgh
Copy link
Author

chadgh commented May 19, 2016

Sure

attr.h
cast.h
common.h
complex.h
descr.h
functional.h
numpy.h
operators.h
pybind11.h
pytypes.h
stl.h
typeid.h

@tbenthompson
Copy link
Owner

tbenthompson commented May 19, 2016

Okay. So, it seems that pybind11 package installed the headers in ./include/site/python3.5 but pybind11.get_include(), which is supposed to return that directory, instead returns /home/chadgh/.pyenv/versions/3.5.1/include/python3.5m/. This is a problem with the pybind11 package.

Wenzel Jakob, who is the maintainer of that project, is usually pretty responsive. Would you be up for opening an issue there?

In the meantime, you can hack things to work properly by opening ./lib/python3.5/site-packages/pybind11/__init__.py and changing

return os.path.dirname(
            locations.distutils_scheme('pybind11', *args, **kwargs)['headers'])

to just have the hardcoded path where the pybind11/pybind11.h file is: In your case YOURVIRTUALENVPATHNAME/include/site.

@chadgh
Copy link
Author

chadgh commented May 19, 2016

Hmm, @tbenthompson your suggestion didn't seem to work I replace the line you specified with:

return '/home/chadgh/.virtualenvs/tmp-2ea8e0bcd287cca/include/site/python3.5/pybind11'

And am getting the same error. I've confirmed that that is the location of the directory with all of the .h files.

Also, according to @wjakob this looks like it might be a pip issue. pypa/pip#3696

@chadgh
Copy link
Author

chadgh commented May 19, 2016

I did just confirm that if I avoid the virtualenv, the example works.

@tbenthompson
Copy link
Owner

tbenthompson commented May 19, 2016

Glad we got to the root of the problem. Thanks for reporting this.

With your hack fix, the pybind11 at the end of the line is the problem. It should be:

return '/home/chadgh/.virtualenvs/tmp-2ea8e0bcd287cca/include/site/python3.5'

@timbicker
Copy link

I have the same problem with python 3.7.

@tbenthompson
Copy link
Owner

Did you read through the posts above? This would be a problem with the installation of pybind11, its interaction with pip and the function pybind11.get_include(). There's nothing cppimport can do to fix it, but if you read through the posts above, there's a hack of that function that would probably work for you. Also, you can go look here for what seems like the latest update on the odyssey of fixing this problem: pybind/pybind11#1190

@jvines
Copy link

jvines commented May 10, 2019

Hi @timbicker ,

I mange to resolve this issue inside a virtualenv of python2.7 by installing pybind11 using conda install pybind11

Hope this helps

@timbicker
Copy link

Thanks for your help, I could solve the problem by doing the apt installs from the installation instruction.

@simonhughes22
Copy link

Installing pybind11 with conda first fixed it for me, as per @jvines' suggestion

@TeamATR
Copy link

TeamATR commented Jan 23, 2020

I got the same error when I tried to install scipy. Is this topic related? It has been raised in Dec 2019. I am wondering how it is going? Any clue now?

@tbenthompson
Copy link
Owner

That scipy issue does seem similar. You might find some useful information scrolling back through this issue and some of the other linked issues.

@Adblu
Copy link

Adblu commented Mar 16, 2020

Same issue here:

1.  pip to install
2. ubuntu 18.04
3. Python 3.6
4. Virtualenv

How to fix it ?

@Adblu
Copy link

Adblu commented Mar 16, 2020

Hi @timbicker ,

I mange to resolve this issue inside a virtualenv of python2.7 by installing pybind11 using conda install pybind11

Hope this helps

Thanks, it helped !

@Abduhu
Copy link

Abduhu commented Sep 11, 2020

I had same problem. It seems that pip does not include pybind11 properly. Hence, I reinstalled pybind11 manully after cloning the package from github repository.
Resume: install pybind11 by pybind11/setup.py instead of pip of Pypi

@tbenthompson
Copy link
Owner

I had same problem. It seems that pip does not include pybind11 properly. Hence, I reinstalled pybind11 manully after cloning the package from github repository.
Resume: install pybind11 by pybind11/setup.py instead of pip of Pypi

It seems like the PyPI (pip) pybind11 package works for some people and not others. Have you tried the conda pybind11 package? That seems to consistently work, but obviously is useless if you're not using conda.

@tanzhenyu
Copy link

Hi @timbicker ,

I mange to resolve this issue inside a virtualenv of python2.7 by installing pybind11 using conda install pybind11

Hope this helps

I can confirm this works with python3.8 as well.

@dman82499
Copy link

dman82499 commented Apr 4, 2021

just confirmed the pip installation of pybind does not install the .h files for me as well, weird. Using windows with python 3.7.4. However, using pip install pybind11[global] fixed the issue for me.

@tbenthompson
Copy link
Owner

just confirmed the pip installation of pybind does not install the .h files for me as well, weird. Using windows with python 3.7.4. However, using pip install pybind11[global] fixed the issue for me.

Glad you got the issue resolved! You might leave post an issue to the pybind11 github issue tracker.

@borgarpa
Copy link

borgarpa commented Jun 17, 2021

Hi @timbicker ,

I mange to resolve this issue inside a virtualenv of python2.7 by installing pybind11 using conda install pybind11

Hope this helps

It didn't work for me tho... I don't know why, but in my conda env it is just impossible for me to get pybind11 to work...

Full error prompt bellow:

Building wheel for torch-cluster (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/borgarpa/miniconda3/envs/torch-points_rocm/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/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'"'"'))' bdist_wheel -d /tmp/pip-wheel-ke6svzxy
       cwd: /tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/
  Complete output (34 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/torch_cluster
  copying torch_cluster/nearest.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/graclus.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/__init__.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/rw.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/grid.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/knn.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/fps.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/sampler.py -> build/lib.linux-x86_64-3.8/torch_cluster
  copying torch_cluster/radius.py -> build/lib.linux-x86_64-3.8/torch_cluster
  running build_ext
  building 'torch_cluster._sampler_cpu' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/tmp
  creating build/temp.linux-x86_64-3.8/tmp/pip-install-uy795qau
  creating build/temp.linux-x86_64-3.8/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e
  creating build/temp.linux-x86_64-3.8/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc
  creating build/temp.linux-x86_64-3.8/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc/cpu
  gcc -pthread -B /home/borgarpa/miniconda3/envs/torch-points_rocm/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc -I/home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include -I/home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/TH -I/home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/THC -I/home/borgarpa/miniconda3/envs/torch-points_rocm/include/python3.8 -c /tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc/sampler.cpp -o build/temp.linux-x86_64-3.8/tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc/sampler.o -fPIC -D__HIP_PLATFORM_HCC__=1 -O2 -DAT_PARALLEL_OPENMP -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1013" -DTORCH_EXTENSION_NAME=_sampler_cpu -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
  cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
  In file included from /home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/python.h:12,
                   from /home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/torch/extension.h:6,
                   from /tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc/cpu/sampler_cpu.h:3,
                   from /tmp/pip-install-uy795qau/torch-cluster_5100622c4e9142d2a68c48fb894edc3e/csrc/sampler.cpp:4:
  /home/borgarpa/miniconda3/envs/torch-points_rocm/lib/python3.8/site-packages/torch/include/torch/csrc/utils/pybind.h:6:10: fatal error: pybind11/pybind11.h: No such file or directory
      6 | #include <pybind11/pybind11.h>
        |          ^~~~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for torch-cluster

@tbenthompson
Copy link
Owner

Hi @borgarpa

I don't have a solution for you, but I just wanted to mention something that looks a bit funny to me. In the gcc command from your output, I don't see the pybind11 include directories being included with a -I. You might check the output of

import pybind11
pybind11.get_include()

That folder should show up in the gcc command.

For me, I get:

(cppimport) ➜  ~ python
Python 3.9.1 | packaged by conda-forge | (default, Jan 10 2021, 02:55:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybind11
>>> pybind11.get_include()
'/home/tbent/.miniconda3/envs/cppimport/lib/python3.9/site-packages/pybind11/include'

@DSRajesh
Copy link

Hi @borgarpa

I don't have a solution for you, but I just wanted to mention something that looks a bit funny to me. In the gcc command from your output, I don't see the pybind11 include directories being included with a -I. You might check the output of

import pybind11
pybind11.get_include()

That folder should show up in the gcc command.

For me, I get:

(cppimport) ➜  ~ python
Python 3.9.1 | packaged by conda-forge | (default, Jan 10 2021, 02:55:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybind11
>>> pybind11.get_include()
'/home/tbent/.miniconda3/envs/cppimport/lib/python3.9/site-packages/pybind11/include'

this worked for me. Thanks Mr. benthompson

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