aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2017-01-06 14:31:14 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-01-06 14:46:14 -0800
commitb59417ecae2e9f334c9971047850cd6ec3fe8d9f (patch)
treed3435fa17fcea49de94626e84faa54dc22319b6e
parenta35e89026cebd3230de8004e7c3b9a014a1b0504 (diff)
Improve error message during ImportError.
Change: 143816105
-rw-r--r--tensorflow/g3doc/get_started/os_setup.md23
-rw-r--r--tensorflow/python/__init__.py8
2 files changed, 27 insertions, 4 deletions
diff --git a/tensorflow/g3doc/get_started/os_setup.md b/tensorflow/g3doc/get_started/os_setup.md
index 345ed01387..bc07c44218 100644
--- a/tensorflow/g3doc/get_started/os_setup.md
+++ b/tensorflow/g3doc/get_started/os_setup.md
@@ -1249,3 +1249,26 @@ RuntimeError: Broken toolchain: cannot link a simple C program
```
This is typically because you have the Xcode build tools installed, but you still need to accept the license agreements. To resolve it, accept the license agreement by opening Xcode, or by running `xcodebuild -license` from the command line.
+
+### Import Error
+When importing tensorflow, you may see an "ImportError" raised. Below
+are some possible examples and solutions:
+
+```
+ImportError: /lib64/libc.so.6: version `GLIBC_2.16' not found (required by ..._pywrap_tensorflow.so)
+```
+
+This can occur if your operating system libraries are too old for
+our provided pip package binaries. Solution: Try
+[building from sources](#installing-from-sources).
+
+```
+ImportError: cannot import name pywrap_tensorflow
+```
+
+This can occur if you happen to be in the tensorflow source code directory
+and try to import tensorflow: the order of search path prefers the current
+directory, and so tries to import directly from the source code instead of
+your installed tensorflow package. Solution: don't import tensorflow
+from the tensorflow source code root directory, if you are.
+
diff --git a/tensorflow/python/__init__.py b/tensorflow/python/__init__.py
index b25c31952e..4819b0a355 100644
--- a/tensorflow/python/__init__.py
+++ b/tensorflow/python/__init__.py
@@ -65,10 +65,10 @@ try:
# use `dlopen()` for dynamic loading.
from tensorflow.python import pywrap_tensorflow
except ImportError:
- msg = """%s\n\nError importing tensorflow. Unless you are using bazel,
-you should not try to import tensorflow from its source directory;
-please exit the tensorflow source tree, and relaunch your python interpreter
-from there.""" % traceback.format_exc()
+ msg = """%s\n\nFailed to load the native TensorFlow runtime.\n
+See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error\n
+for some common reasons and solutions. Include the entire stack trace
+above this error message when asking for help.""" % traceback.format_exc()
raise ImportError(msg)
# Protocol buffers