Tensorflow: ImportError: DLL load failed: Cannot find module

Tensorflow: ImportError: DLL load failed: Cannot find module

使用 tensorflow 时我收到以下错误消息:

C:\Users\Marie\AppData\Local\Programs\Python\Python37\python.exe C:/Users/Marie/Documents/emma&marie/mic/deepvoxnet/demo/demo_rthn.py
Traceback (most recent call last):
  File "C:\Users\Marie\AppData\Local\Programs\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: Kan opgegeven module niet vinden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\__init__.py", line 3, in <module>
    from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>

    from tensorflow.python.eager import context
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <mo
dule>
    from tensorflow.python import pywrap_tfe
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <modul
e>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in
 <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Marie\AppData\Local\Programs\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: Kan opgegeven module niet vinden.


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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Marie/Documents/emma&marie/mic/deepvoxnet/demo/demo_rthn.py", line 9, in <module>
    import keras
  File "C:\Users\Marie\AppData\Local\Programs\Python\Python37\lib\site-packages\keras\__init__.py", line 6, in <module>
    'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`

Process finished with exit code 1

好像找不到模块py_wrap。这是一个相对常见的问题,我在网上找到了很多解决方案,但似乎没有一个有效...我正在使用 python 的 64 位版本并尝试了很多方法来解决这个问题;降级 tensorflow(这不是一个选项,因为另一个软件包 keras 需要 tensorflow 2.2),重新安装 seaborn 和 tensorflow 以及这里提供的几乎所有其他解决方案。怎么了?

看来您使用的是 Keras 最高版本的 Tensorflow 1。

关注 their GitHub 上的 Keras 公告。尝试将 Tensorflow 1 的 Keras 版本降级到 2.2.5 或更低版本和 Tensorflow 2 的 2.4.0。

但是,如果你想使用 Tensorflow 2,他们建议使用经常更新的 Tensorflow 中的 Keras(查看 Github:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/python/keras