您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了tensorflow安裝成功import tensorflow出現問題怎么辦,內容簡而易懂,希望大家可以學習一下,學習完之后肯定會有收獲的,下面讓小編帶大家一起來看看吧。
在安裝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出現問題怎么辦的內容,如果你們有學習到知識或者技能,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。