当我尝试从 keras.preprocessing.image 导入 img_to_array 时,出现以下错误
Using TensorFlow backend.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
c:\python\python37\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: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-6-084051e32a16> in <module>
----> 1 from keras.preprocessing.image import img_to_array
c:\python\python37\lib\site-packages\keras\__init__.py in <module>
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
c:\python\python37\lib\site-packages\keras\utils\__init__.py in <module>
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7 from . import losses_utils
8 from . import metrics_utils
c:\python\python37\lib\site-packages\keras\utils\conv_utils.py in <module>
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
c:\python\python37\lib\site-packages\keras\backend\__init__.py in <module>
----> 1 from .load_backend import epsilon
2 from .load_backend import set_epsilon
3 from .load_backend import floatx
4 from .load_backend import set_floatx
5 from .load_backend import cast_to_floatx
c:\python\python37\lib\site-packages\keras\backend\load_backend.py in <module>
88 elif _BACKEND == 'tensorflow':
89 sys.stderr.write('Using TensorFlow backend.\n')
---> 90 from .tensorflow_backend import *
91 else:
92 # Try and load external backend.
c:\python\python37\lib\site-packages\keras\backend\tensorflow_backend.py in <module>
3 from __future__ import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.eager import context
7 from tensorflow.python.framework import device as tfdev
c:\python\python37\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:\python\python37\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:\python\python37\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:\python\python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
如何解决这个问题?我正在使用 Python-3.7 和 tensorflow-2.4.1。 我也下载了 msvcp71.dll 和 msvcr71.dll 并放置在 System32 文件夹中,但仍然无法解决此错误。
请帮忙。 谢谢。
答案 0 :(得分:1)
文件好像丢失了。
尝试将两者都更新到最新版本。
检查你是否有 Numpy。
更新点:
python -m pip install --upgrade pip
如果版本不兼容,请尝试重新安装两者(可能安装过程中没有下载)。