My code is
import tensorflow as tf
from keras.models import load_model
from keras.preprocessing.sequence import pad_sequences
I have the error import tensorflow.compat.v2 as tf
ModuleNotFoundError: No module named ‘tensorflow.compat’
I don’t understand. I install the last version of tensorflow.
Hi @Regis_Meyssonnier
Welcome to the TensorFlow Forum!
Please provide us some more details like which system OS are you using, the installed Tensorflow and python version. Also, could you please try importing these libraries using below code:
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras.utils import pad_sequences
Nom du système d’exploitation |
Microsoft Windows 10 Famille |
Version |
10.0.19045 Build 19045 |
Autre description du système d’exploitation |
Non disponible |
Fabricant du système d’exploitation |
Microsoft Corporation |
Ordinateur |
DESKTOP-4R9AT4U |
Fabricant |
ASUSTeK COMPUTER INC. |
Modèle |
ROG STRIX G15DK_G15DK |
Type |
PC à base de x64 |
Référence (SKU) du système |
|
Processeur |
AMD Ryzen 7 5800X 8-Core Processor, 4601 MHz, 8 cœur(s), 16 processeur(s) logique(s) |
Version du BIOS/Date |
ASUSTek COMPUTER INC. 204, 25/05/2021 |
When i use your code, i have this error now.
from tensorflow.keras.models import load_model
ModuleNotFoundError: No module named 'tensorflow.keras'
i use Python 3.9.13 and tensorflow2.14
I am able to import these libraries successfully using python 3.10 and TensorFlow 2.14 in macOS. It seems, TensorFlow has not installed in your system correctly.
Please refer to this TF install official page and verify that you have followed all the steps mentioned in the link as per your SystemOS.
Let us know if the issue still persists. Thank you.