python导入 tensorflow DLL文件找不到

import tensorflow as tf


Traceback (most recent call last):
  File "", line 1, in
  File "D:\python35\lib\site-packages\tensorflow\__init__.py", line 24, in le>
    from tensorflow.python import *
  File "D:\python35\lib\site-packages\tensorflow\python\__init__.py", line 72, i
n
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 18, in swig_import_helper
    return importlib.import_module(mname)
  File "D:\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 906, in create_module
  File "", 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:\python35\lib\site-packages\tensorflow\python\__init__.py", line 66, i
n
    from tensorflow.python import pywrap_tensorflow
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 21, in
    _pywrap_tensorflow = swig_import_helper()
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "D:\python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_st
arted/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

百度发现,原来是没有MSVCP140.DLL模块。
所以我就在计算机中搜索MSVCP140.DLL搜索到之后,再把位置配到path环境变量中,如下

D:\python35\Lib\site-packages\matplotlib\MSVCP140.DLL

然后关闭cmd,再重新打开,再import tensorflow as tf。没想到还是报错。

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\Users\Administrator.USER-20160819BJ>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 18, in swig_import_helper
    return importlib.import_module(mname)
  File "D:\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 906, in create_module
  File "", 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:\python35\lib\site-packages\tensorflow\python\__init__.py", line 66, i
n
    from tensorflow.python import pywrap_tensorflow
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 21, in
    _pywrap_tensorflow = swig_import_helper()
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "D:\python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in
  File "D:\python35\lib\site-packages\tensorflow\__init__.py", line 24, in le>
    from tensorflow.python import *
  File "D:\python35\lib\site-packages\tensorflow\python\__init__.py", line 72, i
n
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 18, in swig_import_helper
    return importlib.import_module(mname)
  File "D:\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 906, in create_module
  File "", 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:\python35\lib\site-packages\tensorflow\python\__init__.py", line 66, i
n
    from tensorflow.python import pywrap_tensorflow
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 21, in
    _pywrap_tensorflow = swig_import_helper()
  File "D:\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow')
  File "D:\python35\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'


Failed to load the native TensorFlow runtime.

See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_st
arted/os_setup.md#import_error

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

到现在我都快气炸了!!!!!!!
我发现搜索到的MSVCP140.DLL在火狐文件夹里还有一份,于是我就心想,难道不是这个,我再把path改成
d:\firefox\MSVCP140.DLL


我再关掉cmd并重新打开,再import tensorflow as tf。没想到还是报错
 简直快气死了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

就在这时,我突然灵机一动,以前配java.exe javac.exe的path时,都是配到他们所在的文件夹,要不然我把path的值改成

D:\python35\Lib\site-packages\matplotlib试试

我再关掉cmd并重新打开,再import tensorflow as tf,哇塞幸运之星降临啦!!!!!!!!!!!!!!!!!

windows真是大小写不分,改成msvcp.dll也可以。


现在想,还是对windows系统不了解,所以就查了查path环境变量:

PATH是路径的意思,PATH环境变量中存放的值,就是一连串的路径。不同的路径之间,用英文的分号(;)分隔开。系统执行用户命令时,若用户未给出绝对路径,则首先在当前目录下寻找相应的可执行文件、批处理文件(另外一种可以执行的文件)等。

若找不到,再依次在PATH保存的这些路径中寻找相应的可执行的程序文件。系统就以第一次找到的为准;若搜寻完PATH保存的所有路径都未找到,则会显示类似于图一的错误信息




------------遇到的新错误,更新于2017年6月26日21:44:32-----------------------


ImportError DLL load failed: %1 不是有效的 Win32 应用程序


这是因为,你的matplotlib中的DLL文件不是win64位的,是win32的。

解决方法:把matplotlib删除重新下载,pip3 install matplotlib   (pip install XX 是按装适合python2的第三方包








你可能感兴趣的:(人工机器智能)