Python3.5 win10環(huán)境下導(dǎo)入kera/tensorflow報(bào)錯(cuò)的解決方法
本文實(shí)例講述了Python3.5 win10環(huán)境下導(dǎo)入keras/tensorflow報(bào)錯(cuò)的解決方法。分享給大家供大家參考,具體如下:
我在win10 Python3.5.2安裝keras,然后導(dǎo)入時(shí)報(bào)錯(cuò)如下:
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import keras Using TensorFlow backend. Traceback (most recent call last): File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper return importlib.import_module(mname) File "d:\Anaconda3\envs\tf\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 666, in _load_unlocked File "<frozen importlib._bootstrap>", line 577, in module_from_spec File "<frozen importlib._bootstrap_external>", line 906, in create_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper return importlib.import_module('_pywrap_tensorflow_internal') File "d:\Anaconda3\envs\tf\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named '_pywrap_tensorflow_internal' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "d:\Anaconda3\envs\tf\lib\site-packages\keras\__init__.py", line 3, in <module> from . import activations File "d:\Anaconda3\envs\tf\lib\site-packages\keras\activations.py", line 4, in <module> from . import backend as K File "d:\Anaconda3\envs\tf\lib\site-packages\keras\backend\__init__.py", line 73, in <module> from .tensorflow_backend import * File "d:\Anaconda3\envs\tf\lib\site-packages\keras\backend\tensorflow_backend.py", line 1, in <module> import tensorflow as tf File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\__init__.py", line 24, in <module> from tensorflow.python import * File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module> from tensorflow.python import pywrap_tensorflow File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper return importlib.import_module(mname) File "d:\Anaconda3\envs\tf\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 666, in _load_unlocked File "<frozen importlib._bootstrap>", line 577, in module_from_spec File "<frozen importlib._bootstrap_external>", line 906, in create_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed ImportError: DLL load failed: The specified module could not be found. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper return importlib.import_module('_pywrap_tensorflow_internal') File "d:\Anaconda3\envs\tf\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: No module named '_pywrap_tensorflow_internal' 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.
又臭又長的問題說導(dǎo)入keras時(shí)先導(dǎo)入TensorFlow,然后出現(xiàn)導(dǎo)入失敗,解決方法有兩個(gè):
一.安裝Microsoft Visual C++ 2015 Redistributable Update 3
先在https://www.microsoft.com/en-us/download/details.aspx?id=53587
下載Microsoft Visual C++ 2015 Redistributable Update 3。
然后安裝。
接下來重啟電腦,然后卸載tensorflow:
pip uninstall tensorflow pip uninstall tensorflow-gpu
然后再重裝:
pip install tensorflow pip install tensorflow-gpu
再重新導(dǎo)入應(yīng)該不會(huì)報(bào)錯(cuò)了。
如果無法解決,看下面的方法:
二.cmd下敲命令:
pip install --upgrade --ignore-installed setuptools
更多關(guān)于Python相關(guān)內(nèi)容可查看本站專題:《Python數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Python圖片操作技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》及《Python入門與進(jìn)階經(jīng)典教程》
希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。
相關(guān)文章
python實(shí)現(xiàn)簡單flappy bird
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)簡單flappy bird小游戲,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12python實(shí)現(xiàn)簡單的TCP代理服務(wù)器
這篇文章主要介紹了python實(shí)現(xiàn)簡單的TCP代理服務(wù)器,包含了完整的實(shí)現(xiàn)過程及對(duì)應(yīng)的源碼與說明文檔下載,非常具有參考借鑒價(jià)值,需要的朋友可以參考下2014-10-10用Python編寫生成樹狀結(jié)構(gòu)的文件目錄的腳本的教程
這篇文章主要介紹了用Python編寫生成樹狀結(jié)構(gòu)的文件目錄的腳本的教程,是一個(gè)利用os模塊下各函數(shù)的簡單實(shí)現(xiàn),需要的朋友可以參考下2015-05-05一篇文章教你掌握python數(shù)據(jù)類型的底層實(shí)現(xiàn)
這篇文章主要介紹了Python 數(shù)據(jù)類型的底層實(shí)現(xiàn)原理分析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-09-09Python+Turtle實(shí)現(xiàn)繪制可愛的小倉鼠
肉嘟嘟的小動(dòng)物很是可愛,這篇文章主要為大家介紹一下如何運(yùn)用Python中的turtle庫控制函數(shù)繪制小倉鼠,文中的實(shí)現(xiàn)方法講解詳細(xì),感興趣的可以嘗試一下2022-10-10