To help with this error message, include in your python file: import keras; import tensorflow.keras; and do not include import tensorflow as tf, whereas in the bash file include the version of your tensorflow for example include module load tensorflow//2.16.1-pip-py312-cuda122, I hope this helps to solve the problem.