【发布时间】:2021-04-28 00:31:25
【问题描述】:
我在带有 Python 3.8(我也安装了 Python 3.9 和 3.6)的 Windows 10 上使用 TensorFlow 2.4,在 ml2u 的虚拟环境中,pip install tensorflow 到目前为止只安装了 TensorFlow 2.4。通过尝试在笔记本中导入 TensorFlow,我收到以下错误消息。按照其他帖子中的建议,我安装了 Microsoft Visual C++ Redistributable,从而安装了 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
【问题讨论】:
标签: python c++ python-3.x tensorflow dll