Python3.5 win10环境下导入kera/tensorflow报错的解决方法
本文实例讲述了Python3.5win10环境下导入keras/tensorflow报错的解决方法。分享给大家供大家参考,具体如下:
我在win10Python3.5.2安装keras,然后导入时报错如下:
Python3.5.2|ContinuumAnalytics,Inc.|(default,Jul52016,11:41:13)[MSCv.190064bit(AMD64)]onwin32 Type"help","copyright","credits"or"license"formoreinformation. >>>importkeras UsingTensorFlowbackend. Traceback(mostrecentcalllast): File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line18,inswig_import_helper returnimportlib.import_module(mname) File"d:\Anaconda3\envs\tf\lib\importlib\__init__.py",line126,inimport_module return_bootstrap._gcd_import(name[level:],package,level) File"",line986,in_gcd_import File" ",line969,in_find_and_load File" ",line958,in_find_and_load_unlocked File" ",line666,in_load_unlocked File" ",line577,inmodule_from_spec File" ",line906,increate_module File" ",line222,in_call_with_frames_removed ImportError:DLLloadfailed:Thespecifiedmodulecouldnotbefound. Duringhandlingoftheaboveexception,anotherexceptionoccurred: Traceback(mostrecentcalllast): File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line41,in fromtensorflow.python.pywrap_tensorflow_internalimport* File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line21,in _pywrap_tensorflow_internal=swig_import_helper() File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line20,inswig_import_helper returnimportlib.import_module('_pywrap_tensorflow_internal') File"d:\Anaconda3\envs\tf\lib\importlib\__init__.py",line126,inimport_module return_bootstrap._gcd_import(name[level:],package,level) ImportError:Nomodulenamed'_pywrap_tensorflow_internal' Duringhandlingoftheaboveexception,anotherexceptionoccurred: Traceback(mostrecentcalllast): File" ",line1,in File"d:\Anaconda3\envs\tf\lib\site-packages\keras\__init__.py",line3,in from.importactivations File"d:\Anaconda3\envs\tf\lib\site-packages\keras\activations.py",line4,in from.importbackendasK File"d:\Anaconda3\envs\tf\lib\site-packages\keras\backend\__init__.py",line73,in from.tensorflow_backendimport* File"d:\Anaconda3\envs\tf\lib\site-packages\keras\backend\tensorflow_backend.py",line1,in importtensorflowastf File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\__init__.py",line24,in fromtensorflow.pythonimport* File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\__init__.py",line51,in fromtensorflow.pythonimportpywrap_tensorflow File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line52,in raiseImportError(msg) ImportError:Traceback(mostrecentcalllast): File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line18,inswig_import_helper returnimportlib.import_module(mname) File"d:\Anaconda3\envs\tf\lib\importlib\__init__.py",line126,inimport_module return_bootstrap._gcd_import(name[level:],package,level) File" ",line986,in_gcd_import File" ",line969,in_find_and_load File" ",line958,in_find_and_load_unlocked File" ",line666,in_load_unlocked File" ",line577,inmodule_from_spec File" ",line906,increate_module File" ",line222,in_call_with_frames_removed ImportError:DLLloadfailed:Thespecifiedmodulecouldnotbefound. Duringhandlingoftheaboveexception,anotherexceptionoccurred: Traceback(mostrecentcalllast): File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line41,in fromtensorflow.python.pywrap_tensorflow_internalimport* File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line21,in _pywrap_tensorflow_internal=swig_import_helper() File"d:\Anaconda3\envs\tf\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line20,inswig_import_helper returnimportlib.import_module('_pywrap_tensorflow_internal') File"d:\Anaconda3\envs\tf\lib\importlib\__init__.py",line126,inimport_module return_bootstrap._gcd_import(name[level:],package,level) ImportError:Nomodulenamed'_pywrap_tensorflow_internal' FailedtoloadthenativeTensorFlowruntime. Seehttps://www.tensorflow.org/install/install_sources#common_installation_problems forsomecommonreasonsandsolutions.Includetheentirestacktrace abovethiserrormessagewhenaskingforhelp.
又臭又长的问题说导入keras时先导入TensorFlow,然后出现导入失败,解决方法有两个:
一.安装MicrosoftVisualC++2015RedistributableUpdate3
先在https://www.microsoft.com/en-us/download/details.aspx?id=53587
下载MicrosoftVisualC++2015RedistributableUpdate3。
然后安装。
接下来重启电脑,然后卸载tensorflow:
pipuninstalltensorflow pipuninstalltensorflow-gpu
然后再重装:
pipinstalltensorflow pipinstalltensorflow-gpu
再重新导入应该不会报错了。
如果无法解决,看下面的方法:
二.cmd下敲命令:
pipinstall--upgrade--ignore-installedsetuptools
更多关于Python相关内容可查看本站专题:《Python数学运算技巧总结》、《Python图片操作技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》及《Python入门与进阶经典教程》
希望本文所述对大家Python程序设计有所帮助。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。