Tensorflow 源码安装成功,导入报错 ImportError: cannot import name 'build_info'

December 17, 2023
测试
测试
测试
测试
9 分钟阅读

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

继续阅读

更多来自我们博客的帖子

如何安装 BuddyPress
由 测试 December 17, 2023
经过差不多一年的开发,BuddyPress 这个基于 WordPress Mu 的 SNS 插件正式版终于发布了。BuddyPress...
阅读更多
Filter如何工作
由 测试 December 17, 2023
在 web.xml...
阅读更多
如何理解CGAffineTransform
由 测试 December 17, 2023
CGAffineTransform A structure for holding an affine transformation matrix. ...
阅读更多