Repository navigation
Target //tensorflow/tools/pip_package:build_pip_package failed to build on OSX #72
Description
Activity
Can you try again with
--verbose_failuresand paste in any more information that displays about the failure? Thanks!I am having the same issue today, however I was able to build it yesterday without any problem. I think the problem is that the copts are pointing to
/usr/include/python2.7, which does not exist on OS X (correct path for Homebrew Python is to be found by using the commandpython-config --includes).Here is the log when using
--verbose_failures:± % bazel build --verbose_failures -c opt //tensorflow/tools/pip_package:build_pip_package INFO: Found 1 target... INFO: From Compiling tensorflow/python/client/tf_session_helper.cc: In file included from tensorflow/python/client/tf_session_helper.cc:1: ./tensorflow/python/client/tf_session_helper.h:4:10: fatal error: 'Python.h' file not found #include <Python.h> ^ 1 error generated. ERROR: /Users/jfsantos/Projects/tensorflow/tensorflow/python/BUILD:666:1: C++ compilation of rule '//tensorflow/python:tf_session_helper' failed: osx_gcc_wrapper.sh failed: error executing command (cd /private/var/tmp/_bazel_jfsantos/843612a30412b67e357ec0b01f219282/tensorflow && \ exec env - \ INTERCEPT_LOCALLY_EXECUTABLE=1 \ PATH=/Users/jfsantos/torch/install/bin:/Library/TeX/texbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/Users/jfsantos/.gem/ruby/2.0.0/bin:/usr/local/sbin:/Applications/Julia-0.4.0.app/Contents/Resources/julia/bin \ TMPDIR=/var/folders/z3/s0__77pd3n1bpym4f75hrzbc0000gn/T/ \ tools/cpp/osx_gcc_wrapper.sh '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_darwin-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_darwin-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_darwin-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_darwin-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_darwin-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_darwin-opt/genfiles/third_party/eigen3 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o' -MD -MF bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.d -fPIC -c tensorflow/python/client/tf_session_helper.cc -o bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1: osx_gcc_wrapper.sh failed: error executing command (cd /private/var/tmp/_bazel_jfsantos/843612a30412b67e357ec0b01f219282/tensorflow && \ exec env - \ INTERCEPT_LOCALLY_EXECUTABLE=1 \ PATH=/Users/jfsantos/torch/install/bin:/Library/TeX/texbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/Users/jfsantos/.gem/ruby/2.0.0/bin:/usr/local/sbin:/Applications/Julia-0.4.0.app/Contents/Resources/julia/bin \ TMPDIR=/var/folders/z3/s0__77pd3n1bpym4f75hrzbc0000gn/T/ \ tools/cpp/osx_gcc_wrapper.sh '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -iquote . -iquote bazel-out/local_darwin-opt/genfiles -isystem google/protobuf/src -isystem bazel-out/local_darwin-opt/genfiles/google/protobuf/src -isystem tools/cpp/gcc3 -isystem external/jpeg_archive/jpeg-9a -isystem bazel-out/local_darwin-opt/genfiles/external/jpeg_archive/jpeg-9a -isystem external/png_archive/libpng-1.2.53 -isystem bazel-out/local_darwin-opt/genfiles/external/png_archive/libpng-1.2.53 -isystem external/re2 -isystem bazel-out/local_darwin-opt/genfiles/external/re2 -isystem third_party/gpus/cuda -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda -isystem third_party/gpus/cuda/include -isystem bazel-out/local_darwin-opt/genfiles/third_party/gpus/cuda/include -isystem third_party/eigen3 -isystem bazel-out/local_darwin-opt/genfiles/third_party/eigen3 -I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include -I/usr/include/python2.7 -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o' -MD -MF bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.d -fPIC -c tensorflow/python/client/tf_session_helper.cc -o bazel-out/local_darwin-opt/bin/tensorflow/python/_objs/tf_session_helper/tensorflow/python/client/tf_session_helper.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. Target //tensorflow/tools/pip_package:build_pip_package failed to build INFO: Elapsed time: 3.653s, Critical Path: 2.71sI tried updating the Bazel target for
tf_session_helperintensorflow/python/buildto use the Homebrew include path instead of/usr/include/python2.7, but then I get the following:± % bazel build --verbose_failures -c opt //tensorflow/tools/pip_package:build_pip_package ERROR: /Users/jfsantos/Projects/tensorflow/tensorflow/python/BUILD:666:1: in cc_library rule //tensorflow/python:tf_session_helper: The include path '/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Headers' references a path outside of the execution root.. ERROR: /Users/jfsantos/Projects/tensorflow/tensorflow/python/BUILD:666:1: in cc_library rule //tensorflow/python:tf_session_helper: The include path '/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Headers' references a path outside of the execution root.. ERROR: Analysis of target '//tensorflow/tools/pip_package:build_pip_package' failed; build aborted. INFO: Elapsed time: 0.409sI managed to run by changing the
numpy_macosx_include_dirto the following:numpy_macosx_include_dir = ["-I/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/include", "-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7"]Using the Homebrew path did not work as stated in the comment above.
@jfsantos that did the trick. For some reason, even using anaconda's Python headers gave me the same error, but using the OSX python path (like the one you provided) worked. Thanks!
De-duping with #187
- added a commit that references this issue
on Oct 16, 2018 - added a commit that references this issue
on Aug 23, 2019 - added a commit that references this issue
on Oct 4, 2019 - added a commit that references this issue
on Dec 6, 2019 - added a commit that references this issue
on May 17, 2022 - added 4 commits that reference this issue
on Apr 24, 2025
I recently checked out the repo