系统规格:
我正在尝试导入张量流...但出现导入错误。请帮我解决这个问题。我尝试遵循...
pip uninstall tensorflow
和
pip install tensorflow
当我执行
pip freeze
时,我看到已安装的具有指定版本的tensorflow包。ImportError Traceback (most recent call last)
~\anaconda3\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-d6579f534729> in <module>
----> 1 import tensorflow
~\anaconda3\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
~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
39
---> 40 from tensorflow.python.eager import context
41
42 # pylint: enable=wildcard-import
~\anaconda3\lib\site-packages\tensorflow\python\eager\context.py in <module>
33 from tensorflow.core.protobuf import config_pb2
34 from tensorflow.core.protobuf import rewriter_config_pb2
---> 35 from tensorflow.python import pywrap_tfe
36 from tensorflow.python import tf2
37 from tensorflow.python.client import pywrap_tf_session
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py in <module>
26
27 # pylint: disable=invalid-import-order,g-bad-import-order, wildcard-import, unused-import
---> 28 from tensorflow.python import pywrap_tensorflow
29 from tensorflow.python._pywrap_tfe import *
~\anaconda3\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\user\anaconda3\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: The specified module could not be found.
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.```
使用Anaconda安装Tensorflow,
使用 Python 3.8 为 Tensorflow 创建单独的环境
conda create --name tf python=3.8 tensorflow
conda activate tf
我不小心删除了这个文件。像
pip uninstall tensorflow==2.3.0
一样卸载TensorFlow并重新安装pip install tensorflow==2.3.0
解决了这个问题。不要忘记重新启动内核
添加我的解决方法/黑客(TF
2.5.0
),以防它对某人有帮助:
就我而言,我已经安装了十几个 Visual C++ Redistributables('05、'08,...一直到 2017 年) - 但 TF 仍然因臭名昭著的
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found
错误而失败。我不想下载并安装另一个可再发行组件,只是为了让 TF 正常工作。 (此外,我已经遇到了几篇帖子,足以让人怀疑安装它是否真的能解决问题。)
根据this SO post,令人讨厌的失败
_pywrap_tensorflow_internal.pyd
只是另一个DLL;所以我
vcruntime140.dll
之外,PYD还取决于vcruntime140_1.dll
。vcruntime140.dll
在 C:/Windows/System32/
中可用(使用 where vcruntime140.dll
检查),但在 vcruntime140_1.dll
中不可用;所以我在我的系统分区 C: 上进行了搜索,并在其他地方找到了多个 vcruntime140_1.dll
的副本,主要是在我的主目录的 AppData/Local/
(用户安装的应用程序)中。vcruntime140_1.dll
复制到 C:/Windows/System32/
中 - 然后错误就消失了。因此,如果即使满足所有记录的要求也出现此错误,请进行一些调试以找到错误的原因。它可能会为您节省大量的挫败感和浪费的带宽。