中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助
鲲鹏小智

编译ScaNN过程中没有Python.h文件的解决办法

问题现象描述

执行编译ScaNN命令过程中提示Python.h: no such file or directory,详细信息如下:

[root@localhost scann]# bazel clean; CC=gcc bazel build -c opt --cxxopt="-std=c++17" --copt=-fsized-deallocation --copt=-w --copt=-O3 --cxxopt=-O3 --copt=-march=armv8.2-a+lse+sve+f64mm --cxxopt=-march=armv8.2-a+lse+sve+f64mm --copt=-msve-vector-bits=256 --cxxopt=-msve-vector-bits=256 :build_pip_pkg
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
DEBUG: /root/.cache/bazel/_bazel_root/feae8769a9a784fcce64ccb472ce84a7/external/rules_python/python/repositories.bzl:32:10: py_repositories is a no-op and is deprecated. You can remove this from your WORKSPACE file
WARNING: /root/.cache/bazel/_bazel_root/feae8769a9a784fcce64ccb472ce84a7/external/local_config_tf/BUILD:9275:8: target 'libtensorflow_framework.so.2' is both a rule and a file; please choose another name for the rule
INFO: Analyzed target //:build_pip_pkg (102 packages loaded, 2195 targets configured).
INFO: Found 1 target...
INFO: From Generating C++ proto_library //scann/proto:hashed_proto:
scann/proto/hashed.proto:19:1: warning: Import scann/data_format/features.proto is unused.
ERROR: /home/wjh/scann/google-research/scann/scann/scann_ops/cc/python/BUILD.bazel:8:17: Compiling scann/scann_ops/cc/python/scann_pybind.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall                  -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 113 arguments skipped)
In file included from external/pybind11/include/pybind11/detail/../attr.h:13,
                 from external/pybind11/include/pybind11/detail/class.h:12,
                 from external/pybind11/include/pybind11/pybind11.h:13,
                 from scann/scann_ops/cc/python/scann_pybind.cc:19:
external/pybind11/include/pybind11/detail/../detail/common.h:208:10: fatal error: Python.h: No such file or directory
  208 | #include <Python.h>
      |          ^~~~~~~~~~
compilation terminated.
Target //:build_pip_pkg failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 24.757s, Critical Path: 22.47s
INFO: 694 processes: 196 internal, 498 local.
FAILED: Build did NOT complete successfully

关键过程、根本原因分析

ScaNN编译过程中需要引用Python.h头文件,由于未设置python的头文件路径,导致编译提示Python.h: no such file or directory类信息。

结论、解决方案及效果

  1. 确认是否安装python3-devel开发包。
    1. 确认“/usr/include/python3.9/”路径下是否存在Python.h文件。
      ls -al  /usr/include/python3.9/Python.h

    2. 若不存在,则执行下列命令安装python3-devel开发包。
      yum install python3-devel
  2. 将python3头文件路径添加到环境变量C_INCLUDE_PATH和CPLUS_INCLUDE_PATH中,根据实际安装路径设置参数,例如:
    1
    2
    export C_INCLUDE_PATH=/usr/include/python3.9:$C_INCLUDE_PATH
    export CPLUS_INCLUDE_PATH=/usr/include/python3.9:$CPLUS_INCLUDE_PATH
    
  3. 重新执行编译ScaNN命令。
    bazel clean; CC=gcc bazel build -c opt --cxxopt="-std=c++17" --copt=-fsized-deallocation --copt=-w --copt=-O3 --cxxopt=-O3 --copt=-march=armv8.2-a+lse+sve+f64mm --cxxopt=-march=armv8.2-a+lse+sve+f64mm --copt=-msve-vector-bits=256 --cxxopt=-msve-vector-bits=256 :build_pip_pkg
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词