python tensorflow导入dll加载失败

2024-06-10 00:39:34 发布

您现在位置:Python中文网/ 问答频道 /正文

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

然后用pip3为cpu安装tensorflow

C:\>pip3 install tensorflow

然而,当我试图在python中导入tensorflow时

它告诉我下面的错误

<>我确信我已经安装了微软Visual C++ 2015可重分发(X64)

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

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

那么到底是什么问题

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

我的操作系统:windows 7 enterprise with service pack 1/64位/intel core 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.

Tags: inimportlocaltensorflowlineimportlibbootstrapusers
3条回答

在Win764bit上,tensorflow1.6-CPU也有同样的问题(Intel Core 2 Duo-CPU T6670 2.2GHz)

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

引用此问题: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重新安装

希望这个。我可以帮你。

我在tensorflow-1.12.0中遇到了同样的问题 我所做的是:

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

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

我将tensorflow降级到1.10.0,它修复了这个问题

相关问题 更多 >