python tensorflow导入DLL加载失败

问题描述 投票:4回答:4

我安装了最新的python 3.6.4 x64版本

然后使用pip3为cpu-only安装tensorflow

C:\>pip3 install tensorflow

但是当我尝试在python中导入tensorflow时

它向我显示了以下错误

我确信我已经安装了Microsoft Visual C ++ 2015 Redistributable(x64)

所以它不会是dll msvcp140.dll丢失的问题

它说“DLL加载失败,错误代码为-1073741795”

那么究竟是什么问题呢

我找不到有关此错误代码的任何其他信息

我的操作系统:Windows 7企业版服务包1/64位/英特尔酷睿i5 M 540

>>> import tensorflow
Traceback (most recent call last):
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
python tensorflow dll
4个回答
4
投票

在win7 64bit(Intel Core 2 Duo Cpu T6670 2.2GHz)上,我遇到了与tensorflow1.6-CPU相同的问题

在我找到这个之后,它解决了我的问题。

参考这个问题:https://github.com/tensorflow/tensorflow/issues/17386

通过此tensorflow-1.6.0-cp36-cp36m-win_amd64.whl重新安装:https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2

希望这个.whl可以帮助你。


1
投票

我遇到了与tensorflow-1.12.0相同的问题我所做的是:

  1. 安装anaconda
  2. 打开anaconda提示
  3. conda create -n tfp python=3.6
  4. activate tfp
  5. conda install tensorflow
  6. python
  7. 现在通过导入tensorflow来检查

我使用的版本是3.6,但你也可以试试3.7希望它有所帮助!


1
投票

我将张量流量降级到1.10.0并解决了这个问题


1
投票

可能,您的CPU没有AVX的指令(自1.6以来所有tensorflow二进制文件都需要)。您可以使用CPU-Z等工具进行检查。如果是这种情况,你可以在这里下载正确的轮子(使用SSE2二进制文件):

tensorflow-windows-wheel

© www.soinside.com 2019 - 2024. All rights reserved.