【问题标题】:Tensorflow: ImportError: DLL load failed: Cannot find moduleTensorflow:ImportError:DLL加载失败:找不到模块
【发布时间】:2021-02-14 04:55:40
【问题描述】:

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

【问题讨论】:

    标签: python tensorflow keras importerror


    【解决方案1】:

    您似乎正在使用具有最高 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

    【讨论】:

    • 我把keras降级到2.2.5,最后一条错误信息现在没有了,但是importerrors还在
    • 我也不明白为什么我似乎在使用 tensorflow 1?我在安装时指定了版本并选择了 2.3.1
    • 因为之前我也遇到过那个bug,当时我的问题是因为Tensorflow 1和Keras的冲突。有你的问题,可以试试this solution(galocen的回答)吗?
    • 将 tensorflow 降级到 2.0 并安装 Visual C++ 成功!
    • @M19rie 很好,但我建议您将代码转换为使用tf.keras 而不是 Keras repo,它会自动适应所有 Tensorflow 版本
    猜你喜欢
    • 1970-01-01
    • 2020-10-26
    • 1970-01-01
    • 2019-03-07
    • 2013-12-10
    • 2018-08-13
    • 2020-02-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多