Windows下安装Tensorflow报错 “DLL load failed:找不到指定的模块"

时间:2023-12-24 15:42:31

  Windows下安装完tensorflow后,在cmd下运行python后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’

  
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.3版本,没有使用anaconda。又有的说需要安装visual studio 2017,事实上只是vs2017刚好有运行tensorflow的环境,所以我们需要做的只是安装缺少的环境即可。在下面的链接中下载对应版本(23位和64位),进行安装就可以。

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

  继续在cmd下执行python,import tensorflow as tf,不报错即说明安装成功啦。

  附上非官方windows下python extension packages的whl包链接:http://www.lfd.uci.edu/~gohlke/pythonlibs/

  

版权声明:

作者:王老头
出处:http://www.cnblogs.com/wmr95/p/7677791.html
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,并在文章页面明显位置给出原文链接,否则,作者将保留追究法律责任的权利。