tensorflow安装成功import tensorflow 出现问题
作者:独脚行 时间:2022-04-13 20:35:26
在安装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该问题讨论
来源:https://blog.csdn.net/qq_27276951/article/details/85942108
标签:tensorflow,import
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python实现事件驱动
2022-01-07 10:20:48
MySQL命令终端有beep声
2009-02-26 15:27:00
python实现翻转棋游戏(othello)
2022-06-02 10:40:19
![](https://img.aspxhome.com/file/2023/9/125049_0s.jpg)
Python实现基于KNN算法的笔迹识别功能详解
2021-06-18 13:15:08
![](https://img.aspxhome.com/file/2023/6/72036_0s.png)
js插入flash可防止虚线框激活
2009-03-13 13:31:00
Pandas中DataFrame交换列顺序的方法实现
2023-01-21 10:21:08
Python 图像处理之颜色迁移(reinhard VS welsh)
2022-06-08 05:22:31
![](https://img.aspxhome.com/file/2023/1/117371_0s.jpg)
PHP中的排序函数sort、asort、rsort、krsort、ksort区别分析
2023-11-23 11:50:55
Oracle数据库按时间进行分组统计数据的方法
2023-07-14 13:52:56
python初学之用户登录的实现过程(实例讲解)
2023-03-16 17:27:37
django 2.0更新的10条注意事项总结
2023-05-22 10:48:35
python爬取酷狗音乐排行榜
2021-01-24 19:43:49
跟老齐学Python之玩转字符串(3)
2021-12-09 23:25:53
Firefox扩展工具:Firebug调试经验与技巧
2008-10-31 13:16:00
![](https://img.aspxhome.com/file/UploadPic/200810/31/firebug1-99s.png)
Python 拷贝对象(深拷贝deepcopy与浅拷贝copy)
2022-04-07 09:50:44
![](https://img.aspxhome.com/file/2023/1/101721_0s.gif)
浅谈如何重构冗长的Python代码
2021-11-13 05:48:27
javascript农历日历及世界时间代码
2007-12-21 13:25:00
![](https://img.aspxhome.com/file/UploadPic/200712/21/20071221134028383s.gif)
Python的Flask框架中实现分页功能的教程
2022-02-22 04:41:09
如何使用共享连接减少空闲的连接数?
2010-05-16 15:15:00
Python json模块dumps、loads操作示例
2023-01-03 20:16:29