tensorflow安装成功import tensorflow 出现问题

所属分类: 脚本专栏 / python 阅读数: 265
收藏 0 赞 0 分享

在安装tensorflow完成后,import tensorflow as tf出现问题,问题如下:

>>> import tensorflow as tf
Traceback (most recent call last):
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
  from tensorflow.python.pywrap_tensorflow_internal import *
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
  _pywrap_tensorflow_internal = swig_import_helper()
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
  _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
 File "I:\Anaconda3\lib\imp.py", line 242, in load_module
  return load_dynamic(name, filename, file)
 File "I:\Anaconda3\lib\imp.py", line 342, in load_dynamic
  return _load(spec)
ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "I:\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
  from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
  from tensorflow.python import pywrap_tensorflow
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
  raise ImportError(msg)
ImportError: Traceback (most recent call last):
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
  from tensorflow.python.pywrap_tensorflow_internal import *
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
  _pywrap_tensorflow_internal = swig_import_helper()
 File "I:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
  _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
 File "I:\Anaconda3\lib\imp.py", line 242, in load_module
  return load_dynamic(name, filename, file)
 File "I:\Anaconda3\lib\imp.py", line 342, in load_dynamic
  return _load(spec)
ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。
 
 
Failed to load the native TensorFlow runtime.
 
See https://www.tensorflow.org/install/errors
 
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

问题原因:

tensorflow的新版本不支持比较老的cpu(我这个老机器表示很桑心)

解决办法:

卸载现有的tensorflow,安装tensorflow1.5版本

依次执行:

pip uninstall tensorflow

pip install tensorflow==1.5 -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

成功

另外其他原因:

报错:
import tensorflow遇到以下报错:

原因分析:
根据报错信息,导入(import)失败的原因是在源目录中导入(import)。

解决办法:
使用cd ..命令回到上一级目录,重新导入(import),导入(import)成功

补充:
在github中也有类似问题-可能不是同一原因导致-的讨论,针对的是“Failed to load the native TensorFlow runtime.“的问题,链接如下。
github该问题讨论

到此这篇关于tensorflow安装成功import tensorflow 出现问题的文章就介绍到这了,更多相关import tensorflow 出现问题内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家

更多精彩内容其他人还在看

使用Python写一个量化股票提醒系统

这篇文章主要介绍了小白用Python写了一个股票提醒系统,迷你版量化系统,完美的实现了实时提醒功能,代码简单易懂,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下
收藏 0 赞 0 分享

Python绘制的二项分布概率图示例

这篇文章主要介绍了Python绘制的二项分布概率图,涉及Python基于numpy、math的数值运算及matplotlib图形绘制相关操作技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

Python Learning 列表的更多操作及示例代码

这篇文章主要介绍了Python Learning-列表的更多操作,需要的朋友可以参考下
收藏 0 赞 0 分享

关于python列表增加元素的三种操作方法

这篇文章主要介绍了关于python列表增加元素的几种操作方法,主要有insert方法,extend方法和append方法,每种方法给大家介绍的非常详细,需要的朋友可以参考下
收藏 0 赞 0 分享

如何在python字符串中输入纯粹的{}

这篇文章主要介绍了如何在python字符串中输入纯粹的{}以及python字符串连接的三种方法,需要的朋友可以参考下
收藏 0 赞 0 分享

浅谈Django的缓存机制

这篇文章主要介绍了浅谈Django的缓存机制,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

Django 限制用户访问频率的中间件的实现

这篇文章主要介绍了Django 限制用户访问频率的中间件的实现,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0 赞 0 分享

示例详解Python3 or Python2 两者之间的差异

这篇文章主要介绍了Python3 or Python2?示例详解两者之间的差异,在本文中给大家介绍的非常详细,需要的朋友可以参考下
收藏 0 赞 0 分享

Python wxpython模块响应鼠标拖动事件操作示例

这篇文章主要介绍了Python wxpython模块响应鼠标拖动事件操作,结合实例形式分析了Python使用wxpython模块创建窗口、绑定事件及相应鼠标事件相关操作技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

使用Python实现一个栈判断括号是否平衡

栈(Stack)在计算机领域是一个被广泛应用的集合,栈是线性集合,访问都严格地限制在一段,叫做顶(top)。这篇文章主要介绍了使用Python实现一个栈判断括号是否平衡,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多