【问题标题】:Getting modulenotfound error when importing tensorflow.keras导入 tensorflow.keras 时出现 modulenotfound 错误
【发布时间】:2021-03-19 13:21:16
【问题描述】:

我正在关注神经九关于如何构建聊天机器人的教程(可以找到 here),我在安装 tensorflow 时遇到了一些问题,但我终于做到了,首先安装 tensorflow-gpu,然后安装 tensorflow。

当我使用这些 tensorflow 导入运行程序时:

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation, Dropout
from tensorflow.keras.optimizers import SGD

我明白了

Traceback (most recent call last):
  File "c:/Users/User/Documents/Python Projects/chatbot/traning.py", line 9, in <module>
    import tensorflow.keras
  File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context
  File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\eager\context.py", line 29, in <module>
    from absl import logging
ModuleNotFoundError: No module named 'absl'

我尝试重新安装 abseil,但没有成功。然后我在网上查了一下,大多数答案都表明这个人已经在 python 2.x 上安装了 abseil,他们只需要使用pip3。我没有 python 2,所以这是不可能的。类似的问题可以找here

【问题讨论】:

  • 您能否编辑您的答案并添加您使用的代码?您是否在此处检查过 GPU 兼容性:(tensorflow.org/install/source_windows#gpu)?你试过简单的pip install absl吗?
  • 看来你需要一个 Nvidia GPU。那是对的吗? (我有一个英特尔高清显卡 4000)。我也试过pip install absl,但它说图书馆不存在。原来命令是pip install absl-py。但是我已经有了这个包,所以我重新安装了它。还是不行。

标签: python python-3.x tensorflow tensorflow2.0 modulenotfounderror


【解决方案1】:

tensorflow-gpu 不正式支持英特尔的显卡(请参考this post)。

然而,我发现有一个项目指出 here 建议 OpenCL Solution 据称可以使用英特尔 GPU (issue where compatibility is refereed)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多