解决windows上安装tensorflow时报错,“DLL load failed: 找不到指定的模块”的问题
装好tensorflow后,我建议大家不要直接用测试用例进行测试(如果没装好的话出现的错误一般都是:module‘tensorflow'hasnoattribute‘constant')。第一次测试时可以在pythonshell里面输入:
importtensorflow
如果没有报错,恭喜你,十有八九是装好了,这时可以再用简单的测试用例测试一下。但我估计没报错的话你也不会看到这篇博客了。。。
事实上,我第一次安装的时候出现了如下错误:
Traceback(mostrecentcalllast):
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line18,inswig_import_helper
returnimportlib.import_module(mname)
File“D:\Python\Python35\lib\importlib__init__.py”,line126,inimport_module
return_bootstrap._gcd_import(name[level:],package,level)
File“frozenimportlib._bootstrap”,line986,in_gcd_import
File“frozenimportlib._bootstrap”,line969,in_find_and_load
File“frozenimportlib._bootstrap”,line958,in_find_and_load_unlocked
File“frozenimportlib._bootstrap”,line666,in_load_unlocked
File“frozenimportlib._bootstrap”,line577,inmodule_from_spec
File“frozenimportlib._bootstrap_external”,line906,increate_module
File“frozenimportlib._bootstrap”,line222,in_call_with_frames_removed
ImportError:DLLloadfailed:找不到指定的模块。
Duringhandlingoftheaboveexception,anotherexceptionoccurred:
Traceback(mostrecentcalllast):
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,line41,inmodule
fromtensorflow.python.pywrap_tensorflow_internalimport*
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line21,inmodule
_pywrap_tensorflow_internal=swig_import_helper()
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line20,inswig_import_helper
returnimportlib.import_module(‘_pywrap_tensorflow_internal')
File“D:\Python\Python35\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“pyshell#0”,line1,inmodule
importtensorflow
File“D:\Python\Python35\lib\site-packages\tensorflow__init__.py”,line24,inmodule
fromtensorflow.pythonimport*
File“D:\Python\Python35\lib\site-packages\tensorflow\python__init__.py”,line51,inmodule
fromtensorflow.pythonimportpywrap_tensorflow
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,line52,inmodule
raiseImportError(msg)
ImportError:Traceback(mostrecentcalllast):
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line18,inswig_import_helper
returnimportlib.import_module(mname)
File“D:\Python\Python35\lib\importlib__init__.py”,line126,inimport_module
return_bootstrap._gcd_import(name[level:],package,level)
File“frozenimportlib._bootstrap”,line986,in_gcd_import
File“frozenimportlib._bootstrap”,line969,in_find_and_load
File“frozenimportlib._bootstrap”,line958,in_find_and_load_unlocked
File“frozenimportlib._bootstrap”,line666,in_load_unlocked
File“frozenimportlib._bootstrap”,line577,inmodule_from_spec
File“frozenimportlib._bootstrap_external”,line906,increate_module
File“frozenimportlib._bootstrap”,line222,in_call_with_frames_removed
ImportError:DLLloadfailed:找不到指定的模块。
Duringhandlingoftheaboveexception,anotherexceptionoccurred:
Traceback(mostrecentcalllast):
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”,line41,inmodule
fromtensorflow.python.pywrap_tensorflow_internalimport*
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line21,inmodule
_pywrap_tensorflow_internal=swig_import_helper()
File“D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,line20,inswig_import_helper
returnimportlib.import_module(‘_pywrap_tensorflow_internal')
File“D:\Python\Python35\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
forsomecommonreasonsandsolutions.Includetheentirestacktrace
abovethiserrormessagewhenaskingforhelp.
之前在网上查安装方法时,大多数都说要装一个Anaconda,但我是直接装的python3.5,所以没装Anaconda,我相信问题不在这里。后来看到有人说装了visualstudio2017解决了这个错误,我想不至于吧,装个tensorflow还要装个visualstudio2017?事实上只是visualstudio2017中刚好有运行tensorflow必须的运行时环境。所以,只要安装一下缺少的运行时环境就可以了,可以在如下网站中按照它的installinstructions进行安装,非常简单,只要注意选对32位和64位的版本就行了。
https://www.microsoft.com/en-us/download/details.aspx?id=53587
装好后tensorflow就可以正常使用了~
总结
到此这篇关于解决windows上安装tensorflow时报错,“DLLloadfailed:找不到指定的模块”的问题的文章就介绍到这了,更多相关windows上安装tensorflow报错内容请搜索毛票票以前的文章或继续浏览下面的相关文章希望大家以后多多支持毛票票!