Tensorflow 2.4 - 导入 _pywrap_tensorflow_internal 时 DLL 加载失败

时间:2021-01-23 20:02:33

标签: python c++ python-3.x tensorflow dll

我在 Windows 10 上使用 TensorFlow 2.4 和 Python 3.8(我也安装了 Python 3.9 和 3.6)在虚拟环境 ml2u 中,到目前为止 pip install tensorflow 只安装了 TensorFlow 2.4。通过尝试在笔记本中导入 TensorFlow,我收到了以下错误消息。按照其他帖子的建议,我安装了 Microsoft Visual C++ 可再发行组件,这导致安装了 MS Visual 和 VC_redist.x64.exe

import tensorflow as tf

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     63   try:
---> 64     from tensorflow.python._pywrap_tensorflow_internal import *
     65   # This try catch logic is because there is no bazel equivalent for py_extension.

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf

c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\__init__.py in <module>
     39 import sys as _sys
     40 
---> 41 from tensorflow.python.tools import module_util as _module_util
     42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     43 

c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\__init__.py in <module>
     37 # go/tf-wildcard-import
     38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
---> 39 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
     40 
     41 from tensorflow.python.eager import context

c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     81 for some common reasons and solutions.  Include the entire stack trace
     82 above this error message when asking for help.""" % traceback.format_exc()
---> 83   raise ImportError(msg)
     84 
     85 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
  File "c:\users\lenovo\appdata\local\programs\python\python38\scripts\ml2u\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

----

The shell produced followint output while running jupyter:
[W 20:51:12.010 NotebookApp] Notebook Untitled.ipynb is not trusted
[I 20:51:14.060 NotebookApp] Kernel started: 0d0455bd-ade8-4128-b273-0b24e8d9228f, name: ml2u

1 个答案:

答案 0 :(得分:0)

您可能会遇到此问题,因为您运行的是 32 位 python 或 32 位操作系统。还要检查您的 CPU 是否支持 AVX 指令。

请查看 system requirements 并检查您是否安装了正确的依赖项。

相关问题