ImportError: cannot import name ‘build_info’
ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directory to outside the TensorFlow source tree, and relaunch your Python interpreter from there
https://github.com/tensorflow/tensorflow/issues/13526
Installing collected packages: setuptools, numpy, tensorflow Found existing installation: setuptools 40.6.2 Uninstalling setuptools-40.6.2: Successfully uninstalled setuptools-40.6.2 Found existing installation: numpy 1.15.4 Uninstalling numpy-1.15.4: Successfully uninstalled numpy-1.15.4 Successfully installed numpy-1.14.5 setuptools-39.1.0 tensorflow-1.10.1 zhangjun@zhangjun-desktop:~/tensorflow$ python Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type “help”, “copyright”, “credits” or “license” for more information. import tensorflow as tf Traceback (most recent call last): File “/home/zhangjun/tensorflow/tensorflow/python/platform/self_check.py”, line 25, in from tensorflow.python.platform import build_info ImportError: cannot import name ‘build_info’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “”, line 1, in File “/home/zhangjun/tensorflow/tensorflow/init.py”, line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File “/home/zhangjun/tensorflow/tensorflow/python/init.py”, line 49, in from tensorflow.python import pywrap_tensorflow File “/home/zhangjun/tensorflow/tensorflow/python/pywrap_tensorflow.py”, line 25, in from tensorflow.python.platform import self_check File “/home/zhangjun/tensorflow/tensorflow/python/platform/self_check.py”, line 27, in raise ImportError("Could not import tensorflow. Do not import tensorflow " ImportError: Could not import tensorflow. Do not import tensorflow from its source directory; change directory to outside the TensorFlow source tree, and relaunch your Python interpreter from there. exit()
如何解决这个报错? 换个路径使用就可以了!
zhangjun@zhangjun-desktop:~/tensorflow$ cd zhangjun@zhangjun-desktop:~$ python Python 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609] on linux Type “help”, “copyright”, “credits” or “license” for more information. import tensorflow import tensorflow as tf hello = tf.constant(‘Hello, TensorFlow!’) sess = tf.Session() 2018-12-04 08:46:22.637049: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-12-04 08:46:22.637463: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:01:00.0 totalMemory: 10.91GiB freeMemory: 10.45GiB 2018-12-04 08:46:22.637479: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0 2018-12-04 08:46:22.822172: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-12-04 08:46:22.822203: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0 2018-12-04 08:46:22.822209: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N 2018-12-04 08:46:22.822422: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10106 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1) print(sess.run(hello)) b’Hello, TensorFlow!’