解決windows上安裝tensorflow時(shí)報(bào)錯(cuò),“DLL load failed: 找不到指定的模塊”的問題
最近打算開始研究一下機(jī)器學(xué)習(xí),今天在windows上裝tensorflow花了點(diǎn)功夫,其實(shí)前面的步驟不難,只要依次裝好python3.5,numpy,tensorflow就行了,有一點(diǎn)要注意的是目前只有python3.5能裝tensorflow,最新版的python3.6都不行。
裝好tensorflow后,我建議大家不要直接用測(cè)試用例進(jìn)行測(cè)試(如果沒裝好的話出現(xiàn)的錯(cuò)誤一般都是:module ‘tensorflow' has no attribute ‘constant')。第一次測(cè)試時(shí)可以在python shell里面輸入:
import tensorflow
如果沒有報(bào)錯(cuò),恭喜你,十有八九是裝好了,這時(shí)可以再用簡(jiǎn)單的測(cè)試用例測(cè)試一下。但我估計(jì)沒報(bào)錯(cuò)的話你也不會(huì)看到這篇博客了。。。
事實(shí)上,我第一次安裝的時(shí)候出現(xiàn)了如下錯(cuò)誤:
Traceback (most recent call last):
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 18, in swig_import_helper
return importlib.import_module(mname)
File “D:\Python\Python35\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: 找不到指定的模塊。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”, line 41, in module
from tensorflow.python.pywrap_tensorflow_internal import *
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 21, in module
_pywrap_tensorflow_internal = swig_import_helper()
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 20, in swig_import_helper
return importlib.import_module(‘_pywrap_tensorflow_internal')
File “D:\Python\Python35\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 “pyshell#0”, line 1, in module
import tensorflow
File “D:\Python\Python35\lib\site-packages\tensorflow__init__.py”, line 24, in module
from tensorflow.python import *
File “D:\Python\Python35\lib\site-packages\tensorflow\python__init__.py”, line 51, in module
from tensorflow.python import pywrap_tensorflow
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”, line 52, in module
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 18, in swig_import_helper
return importlib.import_module(mname)
File “D:\Python\Python35\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: 找不到指定的模塊。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”, line 41, in module
from tensorflow.python.pywrap_tensorflow_internal import *
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 21, in module
_pywrap_tensorflow_internal = swig_import_helper()
File “D:\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 20, in swig_import_helper
return importlib.import_module(‘_pywrap_tensorflow_internal')
File “D:\Python\Python35\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.
Seehttps://www.tensorflow.org/install/install_sources
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
之前在網(wǎng)上查安裝方法時(shí),大多數(shù)都說要裝一個(gè)Anaconda,但我是直接裝的python3.5,所以沒裝Anaconda,我相信問題不在這里。后來看到有人說裝了visual studio2017解決了這個(gè)錯(cuò)誤,我想不至于吧,裝個(gè)tensorflow還要裝個(gè)visual studio2017?事實(shí)上只是visual studio2017中剛好有運(yùn)行tensorflow必須的運(yùn)行時(shí)環(huán)境。所以,只要安裝一下缺少的運(yùn)行時(shí)環(huán)境就可以了,可以在如下網(wǎng)站中按照它的install instructions進(jìn)行安裝,非常簡(jiǎn)單,只要注意選對(duì)32位和64位的版本就行了。
https://www.microsoft.com/en-us/download/details.aspx?id=53587
裝好后tensorflow就可以正常使用了~
總結(jié)
到此這篇關(guān)于解決windows上安裝tensorflow時(shí)報(bào)錯(cuò),“DLL load failed: 找不到指定的模塊”的問題的文章就介紹到這了,更多相關(guān)windows上安裝tensorflow報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python類的繼承、多態(tài)及獲取對(duì)象信息操作詳解
這篇文章主要介紹了Python類的繼承、多態(tài)及獲取對(duì)象信息操作,結(jié)合實(shí)例形式較為詳細(xì)的分析了Python面向?qū)ο蟪绦蛟O(shè)計(jì)中類、繼承、多態(tài)等相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2019-02-02OpenCV根據(jù)面積篩選連通域?qū)W習(xí)示例
這篇文章主要為大家介紹了OpenCV根據(jù)面積篩選連通域?qū)W習(xí)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-06-06python?numpy庫(kù)之如何使用matpotlib庫(kù)繪圖
Numpy的主要對(duì)象是同構(gòu)多維數(shù)組,它是一個(gè)元素表,所有類型都相同,由非負(fù)整數(shù)元組索引,在Numpy維度中稱為軸,這篇文章主要介紹了python?numpy庫(kù)?使用matpotlib庫(kù)繪圖,需要的朋友可以參考下2022-10-10Python?numpy中np.random.seed()的詳細(xì)用法實(shí)例
在學(xué)習(xí)人工智能時(shí),大量的使用了np.random.seed(),利用隨機(jī)數(shù)種子,使得每次生成的隨機(jī)數(shù)相同,下面這篇文章主要給大家介紹了關(guān)于Python?numpy中np.random.seed()的詳細(xì)用法,需要的朋友可以參考下2022-08-08使用Python爬蟲庫(kù)requests發(fā)送請(qǐng)求、傳遞URL參數(shù)、定制headers
今天為大家介紹一下Python爬蟲庫(kù)requests的發(fā)送請(qǐng)求、傳遞URL參數(shù)、定制headers的基礎(chǔ)使用方法2020-01-01深入理解Tensorflow中的masking和padding
TensorFlow 是一個(gè)用于人工智能的開源神器,這篇文章主要介紹了Tensorflow中的masking和padding的相關(guān)知識(shí),通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-02-02flask 實(shí)現(xiàn)上傳圖片并縮放作為頭像的例子
今天小編就為大家分享一篇flask 實(shí)現(xiàn)上傳圖片并縮放作為頭像的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-01-01