1

我可以在 Python 中导入 pybind11,它位于包含路径中。但是,按照此处的说明,我收到以下错误:

(venv)[jalal@ivcgpu1 affdex-sdk-py]$ python
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybind11
>>> pybind11.get_include()
'/home/grad3/jalal/venv/include/site/python2.7'
>>> pybind11.get_include(True)
'/home/grad3/jalal/venv/include/site/python2.7'
>>> quit()
(venv)[jalal@ivcgpu1 affdex-sdk-py]$ c++ -O3 -shared -std=c++11 -fPIC -Wl,--no-as-needed -I$AFFDEX_SDK_HOME/include -I$HOME/venv/include/site/python2.7 `python-config --cflags --ldflags --libs` -Wl,--no-as-needed -laffdex-native -L$AFFDEX_SDK_HOME/lib affdex.cpp -o affdex.so
affdex.cpp:9:31: fatal error: pybind11/pybind11.h: No such file or directory
 #include <pybind11/pybind11.h>
                               ^
compilation terminated.
(venv)[jalal@ivcgpu1 affdex-sdk-py]$ 

我该如何解决这个错误?

更新:

(venv)[jalal@ivcgpu1 affdex-sdk-py]$ echo $HOME
/home/grad3/jalal
(venv)[jalal@ivcgpu1 affdex-sdk-py]$ echo $HOME/venv/include/site/python2.7
/home/grad3/jalal/venv/include/site/python2.7
4

2 回答 2

0

您是否尝试在编译命令中添加包含目录?

喜欢-I/[pathToPython]/Lib/site-packages/pybind11/include

于 2021-07-15T12:29:44.560 回答
0

尝试安装时看到以下错误scipy消息pypy

  scipy/fft/_pocketfft/pypocketfft.cxx:15:31: fatal error: pybind11/pybind11.h: No such file or directory
   #include <pybind11/pybind11.h>
                                 ^
  compilation terminated.
  scipy/fft/_pocketfft/pypocketfft.cxx:15:31: fatal error: pybind11/pybind11.h: No such file or directory
   #include <pybind11/pybind11.h>

解决方法是:

$ python -m pip install pybind11
于 2020-02-16T12:11:37.067 回答