Skip to content

Target //tensorflow/tools/pip_package:build_pip_package failed to build on OSX #72

Description

@delip
ERROR: /Users/delip/Softwares/tensorflow/tensorflow/tensorflow.bzl:224:3: C++ compilation of rule '//tensorflow/python:tf_session_helper' failed: osx_gcc_wrapper.sh failed: error executing command 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 ... (remaining 52 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.

I recently checked out the repo

$ git log | head -5
commit 41930f0b81b52a34fb56d921c9bad65c36168323
Author: Vijay Vasudevan <[email protected]>
Date:   Mon Nov 9 18:42:53 2015 -0800

    TensorFlow: Upstream a batch of changes to git.

Activity

  1. mrry commented on Nov 10, 2015

    @mrry
    Contributor

    Can you try again with --verbose_failures and paste in any more information that displays about the failure? Thanks!

  2. jfsantos commented on Nov 10, 2015

    @jfsantos
    Contributor

    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 command python-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.71s
    

    I tried updating the Bazel target for tf_session_helper in tensorflow/python/build to 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.409s
    
  3. jfsantos commented on Nov 10, 2015

    @jfsantos
    Contributor

    I managed to run by changing the numpy_macosx_include_dir to 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.

  4. delip commented on Nov 17, 2015

    @delip
    Author

    @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!

  5. vrv commented on Nov 24, 2015

    @vrv

    De-duping with #187

  6. added a commit that references this issue on Mar 9, 2016
  7. added a commit that references this issue on Oct 16, 2018
  8. added a commit that references this issue on Aug 23, 2019
    cae7b6b
  9. added a commit that references this issue on Oct 4, 2019
    ae4fec8
  10. added a commit that references this issue on Dec 6, 2019
  11. added a commit that references this issue on May 17, 2022
  12. added 2 commits that reference this issue on Mar 4, 2025
  13. added 4 commits that reference this issue on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions