解决Tensorflow安装成功,但在导入时报错的问题
作者:x_lock 时间:2022-03-05 18:39:27
在Mac上按照官网教程安装成功tensor flow后,但在程序中导入时,仍然报错,包括但不限于以下两个错误。对于这种错误,原因主要在于Mac内默认的python库比较老了,即便通过pip命令安装了新的包,python也会默认导入默认位置的包。这时候需要做的就是删除,有冲突的包,对于以下两个错误,就是分别时numpy和six两个包冲突了。
可以在python命令行环境下,通过numpy.version和six.version两个命令查看当前版本,如果与预期的不一致,就可以删掉。
可以通过numpy.path查看默认包的位置。
删掉即可
import tensorflow
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File “”, line 1, in
File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in
from tensorflow.python import *
File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 49, in
from tensorflow.python import pywrap_tensorflow
File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py”, line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py”, line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File “/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”, line 24, in swig_import_helper
_mod = imp.load_module(‘_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Traceback (most recent call last):
File “”, line 1, in
File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in
from tensorflow.python import *
File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 104, in
from tensorflow.python.platform import test
File “/Library/Python/2.7/site-packages/tensorflow/python/platform/test.py”, line 41, in
from tensorflow.python.framework import test_util as _test_util
File “/Library/Python/2.7/site-packages/tensorflow/python/framework/test_util.py”, line 54, in
from tensorflow.python.platform import googletest
File “/Library/Python/2.7/site-packages/tensorflow/python/platform/googletest.py”, line 35, in
from tensorflow.python.platform import benchmark
File “/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py”, line 120, in
class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)):
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.py”, line 566, in with_metaclass
return meta(“NewBase”, bases, {})
File “/Library/Python/2.7/site-packages/tensorflow/python/platform/benchmark.py”, line 115, in new
if not newclass.is_abstract():
AttributeError: type object ‘NewBase' has no attribute ‘is_abstract'
import tensorflow
Traceback (most recent call last):
File “”, line 1, in
File “/Library/Python/2.7/site-packages/tensorflow/init.py”, line 24, in
from tensorflow.python import *
File “/Library/Python/2.7/site-packages/tensorflow/python/init.py”, line 49, in
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
来源:https://blog.csdn.net/x_lock/article/details/77249217
标签:Tensorflow,安装,导入
0
投稿
猜你喜欢
vue中导出Excel表格的实现代码
2024-06-05 09:14:06
各浏览器 CSS Hack 整理
2008-01-17 10:54:00
js substr支持中文截取函数代码(中文是双字节)
2024-04-10 10:44:58
CentOS 7安装MySQL的详细步骤
2024-01-25 19:59:17
在JScript中使用ADODB.Stream判断文件编码
2008-06-08 13:03:00
MySQL修改默认字符集编码的方法
2024-01-26 01:18:52
python处理xml文件的方法小结
2023-10-28 01:53:33
Pytorch实现ResNet网络之Residual Block残差块
2022-11-17 15:00:02
CSS鼠标悬停tip效果
2007-08-26 17:32:00
PHP getallheaders无法获取自定义头(headers)的问题
2024-04-30 08:47:30
javascript函数定义的几种区别小结
2024-04-10 10:40:03
python计算导数并绘图的实例
2023-01-19 21:16:51
显示同一分组中的其他元素的sql语句
2024-01-23 09:38:24
Python列表常用函数使用详解
2021-08-21 01:52:05
使用TensorFlow搭建一个全连接神经网络教程
2023-01-10 10:59:20
Python使用Flask-SQLAlchemy连接数据库操作示例
2024-01-27 10:34:36
详解PHP如何更好的利用PHPstorm的自动提示
2024-05-22 10:05:30
Python get获取页面cookie代码实例
2021-03-29 17:26:49
vue 修改 data 数据问题并实时显示操作
2024-05-02 17:00:53
ECMAScript6函数默认参数
2024-05-13 09:18:24