Issue
When building tensorflow using a virtualenv I get the following error:
fatal error: Python.h: No such file or directory
This usually means that the python-dev package needs to be installed:
sudo apt-get install python3-dev
In my case it is installed but bazel doesn't know where to look for Python.h
because the Python interpreter exists in the virtualenv. Is there a way of including the system's Python header file without changing the bazel workspace?
Solution
Set the PYTHON_INCLUDE_PATH
environment variable before building with bazel (see github issue):
export PYTHON_INCLUDE_PATH="/usr/include/python3.6m"
bazel build ...
You can find this directory path using the following command:
find / -name Python.h 2>/dev/null
Answered By - Alex Answer Checked By - Mary Flores (WPSolving Volunteer)