Stack Exchange
Error with swig_import_helper and PyModule_Create2 when building tensorflow-serving with bazel
I'm trying to install tensorflow-serving using bazel, and when I run 
bazel build tensorflow_serving/... 

to build the source tree, I get this error:
ERROR: /home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/external/org_tensorflow/tensorflow/contrib/session_bundle/example/BUILD:38:1: Executing genrule @org_tensorflow//tensorflow/contrib/session_bundle/example:half_plus_two failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
Traceback (most recent call last):
  File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/tf_serving/../org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.py", line 32, in <module>
    import tensorflow as tf
  File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 48, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /home/saad/.cache/bazel/_bazel_saad/e37842e738e0e762fe833f8c0caa8761/execroot/serving/bazel-out/host/bin/external/org_tensorflow/tensorflow/contrib/session_bundle/example/export_half_plus_two.runfiles/org_tensorflow/tensorflow/python/_pywrap_tensorflow.so: undefined symbol: PyModule_Create2

What do I do?
I'm running python 3.5, gcc/g++ 4.9, CUDA 8.0, have swig installed, and am trying to build on Ubuntu Mate 16.04 with a GTX 1080.
Thanks!
