Skip to content

Commit 251a1e7

Browse files
mrryfrankchn
authored andcommitted
Add an actionable error message for build_info ImportError (tensorflow#13528)
This `import` statement is now the first point where we attempt to import a generated file, and hence could see a failure if the user tries to `import tensorflow` from the root of the git repository source tree. When this `import` fails, raise a more actionable error message. Fixes tensorflow#13526.
1 parent b474e55 commit 251a1e7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tensorflow/python/platform/self_check.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121
import os
2222

2323

24-
from tensorflow.python.platform import build_info
24+
try:
25+
from tensorflow.python.platform import build_info
26+
except ImportError:
27+
raise ImportError("Could not import tensorflow. Do not import tensorflow "
28+
"from its source directory; change directory to outside "
29+
"the TensorFlow source tree, and relaunch your Python "
30+
"interpreter from there.")
2531

2632

2733
def preload_check():

0 commit comments

Comments
 (0)