关于python:ImportError:DLL加载失败:找不到指定的模块

ImportError: DLL load failed: The specified module could not be found. While attempting to import TensorFlow

我在尝试导入TensorFlow时遇到以下错误。我尝试回滚到C++ ReDIST。2015年(2017年起),但仍不工作。Win10,Python 3.5(64)

Traceback (most recent call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper return importlib.import_module(mname)
File"C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File"",
line 986, in _gcd_import File"", line 969, in _find_and_load File"",
line 958, in _find_and_load_unlocked File"", line 666, in
_load_unlocked File"", line 577, in module_from_spec File"", line 914, in create_module File"", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in from tensorflow.python.pywrap_tensorflow_internal import *
File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper return
importlib.import_module('pywrap_tensorflow_internal') File
"C:\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"", line 1, in File
"C:\Python35\lib\site-packages\tensorflow_init_.py", line 24, in from
tensorflow.python import * File
"C:\Python35\lib\site-packages\tensorflow\python_init_.py", line 51,
in from tensorflow.python import pywrap_tensorflow File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 52, in raise ImportError(msg) ImportError: Traceback (most recent
call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper return importlib.import_module(mname)
File"C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File"",
line 986, in _gcd_import File"", line 969, in _find_and_load File"",
line 958, in _find_and_load_unlocked File"", line 666, in
_load_unlocked File"", line 577, in module_from_spec File"", line 914, in create_module File"", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in from tensorflow.python.pywrap_tensorflow_internal import *
File
"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File"C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper return
importlib.import_module('pywrap_tensorflow_internal') File
"C:\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.


我在Windows 10和GTX960M中的工作设置:

  • 安装python 3.5.x
  • Microsoft Visual Studio 2015社区版。
  • 下载并安装CUDA工具包8.0
  • 下载Cudnn v5.1。
  • 在路径中设置cuda_home(cuda)和%cuda_home%in。
  • 将CUDNN文件提取到文件夹中,并将该位置(bin、lib、include文件夹所在的文件夹)添加到路径中,确保在%path%中正确设置了CUDNN DLL。
  • 将各个文件从CUDN复制到CUDA安装目录中的文件夹(这解决了我的问题):将cudnn64_5.dll复制到c:program filesvidia gpu computing toolkitcudav8.0in。将cudnn.h复制到c:program filesvidia gpu computing toolkitcudav8.0include。将cudnn.lib复制到c:program filesvidia gpu computing toolkitcudav8.0libx64。
  • 确保在C:WindowsSystem32和C:WindowsSysWow64中有msvcp140.dll。如果不从这里下载:https://www.microsoft.com/en-us/download/details.aspx?ID=53587并安装。

我强烈认为在这种情况下,这些版本控制有点重要。我尝试使用Cudnn6.0,但失败了。但5.1的人工作。