ModuleNotFoundError: No module named ‘keras.api’

  airflow, docker-compose, dockerfile, keras

I have received an unknown error when running airflow. We do install Keras.

dockerfile

RUN pip install "Keras==2.3.1"

RUN pip install "apache-airflow[celery,devel,postgres,redis,s3,ssh]==1.10.9"

RUN pip install "keras-models==0.0.7"

But we are getting the missing keras.api module. I can’t find keras.api was used anywhere.

ml.scheduler_1   |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ml.scheduler_1   |   File "/robo/airflow/dags/general/video_migration.py", line 5, in <module>
ml.scheduler_1   |     from flows.operators import video_process as videos
ml.scheduler_1   |   File "/robo/flows/operators/video_process.py", line 11, in <module>
ml.scheduler_1   |     from serving.models.ali_audit import AliVideoAbuseDetection
ml.scheduler_1   |   File "/robo/serving/models/__init__.py", line 83, in <module>
ml.scheduler_1   |     _module = loader.find_module(module_name).load_module(module_name)
ml.scheduler_1   |   File "/robo/serving/models/places365.py", line 8, in <module>
ml.scheduler_1   |     from keras_models.models.pretrained import vgg16_places365
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras_models/models/__init__.py", line 1, in <module>
ml.scheduler_1   |     from .linear import build as LinearModel
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras_models/models/linear.py", line 2, in <module>
ml.scheduler_1   |     from keras import Model
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/__init__.py", line 3, in <module>
ml.scheduler_1   |     from . import utils
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/utils/__init__.py", line 26, in <module>
ml.scheduler_1   |     from .vis_utils import model_to_dot
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/utils/vis_utils.py", line 7, in <module>
ml.scheduler_1   |     from ..models import Model
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/models.py", line 12, in <module>
ml.scheduler_1   |     from .engine.training import Model
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/engine/__init__.py", line 8, in <module>
ml.scheduler_1   |     from .training import Model
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/engine/training.py", line 14, in <module>
ml.scheduler_1   |     from . import training_utils
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/engine/training_utils.py", line 17, in <module>
ml.scheduler_1   |     from .. import metrics as metrics_module
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/keras/metrics.py", line 1850, in <module>
ml.scheduler_1   |     BaseMeanIoU = tf.keras.metrics.MeanIoU
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 62, in __getattr__
ml.scheduler_1   |     module = self._load()
ml.scheduler_1   |   File "/usr/local/lib/python3.7/site-packages/tensorflow/python/util/lazy_loader.py", line 45, in _load
ml.scheduler_1   |     module = importlib.import_module(self.__name__)
ml.scheduler_1   |   File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
ml.scheduler_1   |     return _bootstrap._gcd_import(name[level:], package, level)
ml.scheduler_1   | ModuleNotFoundError: No module named 'keras.api'

Source: Dockerfile Questions

LEAVE A COMMENT