windows上安装tensorflow时报错,“DLL load failed: 找不到指定的模块”的解决方式

windows上安装tensorflow时报错,“DLL load failed: 找不到指定的模块”的解决方式

最近打算开始研究一下机器学习,今天在windows上装tensorflow花了点功夫,其实前面的步骤不难,只要依次装好python3.5,numpy,tensorflow就行了,有一点要注意的是目前只有python3.5能装tensorflow,最新版的python3.6都不行。

装好tensorflow后,我建议大家不要直接用测试用例进行测试(如果没装好的话出现的错误一般都是:module ‘tensorflow’ has no attribute ‘constant’)。第一次测试时可以在python shell里面输入:

import tensorflow

如果没有报错,恭喜你,十有八九是装好了,这时可以再用简单的测试用例测试一下。但我估计没报错的话你也不会看到这篇博客了。。。

事实上,我第一次安装的时候出现了如下错误:
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.

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.

之前在网上查安装方法时,大多数都说要装一个Anaconda,但我是直接装的python3.5,所以没装Anaconda,我相信问题不在这里。后来看到有人说装了visual studio2017解决了这个错误,我想不至于吧,装个tensorflow还要装个visual studio2017?事实上只是visual studio2017中刚好有运行tensorflow必须的运行时环境。所以,只要安装一下缺少的运行时环境就可以了,可以在如下网站中按照它的install instructions进行安装,非常简单,只要注意选对32位和64位的版本就行了。

https://www.microsoft.com/en-us/download/details.aspx?id=53587

装好后tensorflow就可以正常使用了~

当你在运行import tensorflow as tf,出现了DLL load failed: 不到指定模块的错误提示。这个错误通常是因为你的电脑缺少了tensorflow所需的某个模块或库文件。 解决这个问题的方法有以下几种: 1. 确保你已经正确地安装tensorflow。你可以使用pip install tensorflow命令来安装tensorflow。请确保在安装过程中没有出现任何错误提示。 2. 检查你的电脑是否已经安装了所有tensorflow所需的依赖项。可以参考tensorflow官方文档或者在安装tensorflow之前运行一些检查命令来确认所有依赖项都已安装。 3. 重新安装tensorflow。你可以使用pip uninstall tensorflow命令来卸载tensorflow,然后再重新安装。确保在卸载和安装过程中没有出现任何错误提示。 如果以上方法都没有解决问题,你可以尝试以下几种进一步的解决方法: 4. 检查你的操作系统是否有更新。有,更新操作系统可以解决一些模块缺失的问题。 5. 检查你的Python环境是否正确配置。确保你的Python环境变量设置正确,并且你正在使用与tensorflow兼容的Python版本。 总结起来,当你遇到import tensorflow as tf DLL load failed: 不到指定模块的错误,你可以尝试重新安装tensorflow,检查依赖项,更新操作系统或者检查Python环境配置。希望这些方法能够解决你的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [(解决方法)tensorflow ImportError: DLL load failed: 不到指定模块。](https://blog.csdn.net/Halsey_/article/details/88411095)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [tensorflow导入报错DLL load failed: 不到指定模块DLL load failed: The specified module could ...](https://blog.csdn.net/z704630835/article/details/87618521)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值