【问题标题】:is there a way to solve importing ternsorflow for keras problem?有没有办法解决导入 tensorflow 的 keras 问题?
【发布时间】:2021-02-04 09:26:27
【问题描述】:
Traceback (most recent call last):
  File "C:\Users\surik\anaconda3\envs\issa\lib\site-packages\keras\__init__.py", line 3, in <module>
    from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
ModuleNotFoundError: No module named 'tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 16, in <module>
    from keras.models import Sequential
  File "C:\Users\surik\anaconda3\envs\issa\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`

我使用的tensorflow版本是2.2.2,keras版本是2.4.3,python版本是3.7.0

【问题讨论】:

  • 你确定你的 tensorflow 版本是 >2.2 吗?你可以再次交叉检查 print(tf.__version__)
  • "ModuleNotFoundError: No module named 'tensorflow'" 这点说明问题是没有安装tensorflow
  • 是的,版本是 2.2.2
  • 看起来您是在虚拟环境中执行此操作。如果是,你记得安装在同一个环境中吗? (这要么是一个容易犯的错误,要么就是我记性不好。或者可能两者兼而有之。)pip list 说什么?

标签: python tensorflow keras pip


【解决方案1】:

尝试将 TensorFlow 直接安装到您的 anaconda 环境中。

【讨论】:

  • 已经安装到环境中但仍然出现同样的错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-03
  • 2022-09-27
  • 2021-05-28
  • 1970-01-01
  • 2021-01-09
  • 2020-01-18
  • 2022-01-21
相关资源
最近更新 更多