【问题标题】:Python.h not found building from Tensorflow from source in virtualenvPython.h 未从 virtualenv 中的源代码从 Tensorflow 构建
【发布时间】:2018-07-26 02:54:46
【问题描述】:

使用 virtualenv 构建 tensorflow 时出现以下错误:

fatal error: Python.h: No such file or directory

这通常意味着需要安装python-dev包:

sudo apt-get install python3-dev

在我的情况下,它已安装,但 bazel 不知道在哪里寻找 Python.h,因为 Python 解释器存在于 virtualenv 中。有没有办法在不包含changing the bazel workspace的情况下包含系统的Python头文件?

【问题讨论】:

    标签: python tensorflow virtualenv


    【解决方案1】:

    在使用 bazel 构建之前设置PYTHON_INCLUDE_PATH 环境变量(参见github issue):

    export PYTHON_INCLUDE_PATH="/usr/include/python3.6m"
    bazel build ...
    

    您可以使用以下命令找到此目录路径:

    find / -name Python.h 2>/dev/null
    

    【讨论】:

    • 这段代码没有解决我的问题:export PYTHON_INCLUDE_PATH="/usr/include/python2.7"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 2018-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多