ModuleNotFoundError: No module named ‘tensorflow.compat.v2‘解决方法
原因:
- tensorflow和keras版本不对齐或者keras版本过高
Framework | Env name | Description |
---|---|---|
TensorFlow 2.2 | tensorflow-2.2 | TensorFlow 2.2.0 + Keras 2.3.1 on Python 3.7. |
TensorFlow 2.1 | tensorflow-2.1 | TensorFlow 2.1.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 2.0 | tensorflow-2.0 | TensorFlow 2.0.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 1.15 | tensorflow-1.15 | TensorFlow 1.15.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 1.14 | tensorflow-1.14 | TensorFlow 1.14.0 + Keras 2.2.5 on Python 3.6. |
TensorFlow 1.13 | tensorflow-1.13 | TensorFlow 1.13.0 + Keras 2.2.4 on Python 3.6. |
TensorFlow 1.12 | tensorflow-1.12 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 3.6. |
tensorflow-1.12:py2 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 2. | |
TensorFlow 1.11 | tensorflow-1.11 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 3.6. |
tensorflow-1.11:py2 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 2. | |
TensorFlow 1.10 | tensorflow-1.10 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 3.6. |
tensorflow-1.10:py2 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 2. | |
TensorFlow 1.9 | tensorflow-1.9 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 3.6. |
tensorflow-1.9:py2 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 2. | |
TensorFlow 1.8 | tensorflow-1.8 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.8:py2 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 2. | |
TensorFlow 1.7 | tensorflow-1.7 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.7:py2 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 2. | |
TensorFlow 1.5 | tensorflow-1.5 | TensorFlow 1.5.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.5:py2 | TensorFlow 1.5.0 + Keras 2.0.8 on Python 2. | |
TensorFlow 1.4 | tensorflow-1.4 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 3.6. |
tensorflow-1.4:py2 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 2. | |
TensorFlow 1.3 | tensorflow-1.3 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 3.6. |
tensorflow-1.3:py2 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 2. |
- 如果不是版本原因
import tensorflow.keras
改为
import tensorflow.keras