tensorflow: 1.10 build fails with "No module named 'keras_applications'"

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Fedora 28
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 1.10
  • Python version: 3.6
  • Bazel version (if compiling from source): 0.16
  • GCC/Compiler version (if compiling from source): 7.3
  • CUDA/cuDNN version: 9.2
  • GPU model and memory: Quadro M2200 4G
  • Exact command to reproduce: bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

Hi, a recent checkout of master (~ 2 hours ago) fails (for me) with

ERROR: /home/key/code/tensorflow/tensorflow/BUILD:584:1: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1)
/home/key/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "/home/key/.cache/bazel/_bazel_key/8de93c72df6c3fec3e289f10fadff72b/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 27, in <module>
    from tensorflow.python.tools.api.generator import doc_srcs
  File "/home/key/.cache/bazel/_bazel_key/8de93c72df6c3fec3e289f10fadff72b/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/__init__.py", line 81, in <module>
    from tensorflow.python import keras
  File "/home/key/.cache/bazel/_bazel_key/8de93c72df6c3fec3e289f10fadff72b/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/keras/__init__.py", line 25, in <module>
    from tensorflow.python.keras import applications
  File "/home/key/.cache/bazel/_bazel_key/8de93c72df6c3fec3e289f10fadff72b/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/create_tensorflow.python_api.runfiles/org_tensorflow/tensorflow/python/keras/applications/__init__.py", line 21, in <module>
    import keras_applications
ModuleNotFoundError: No module named 'keras_applications'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3855.754s, Critical Path: 156.93s
INFO: 8932 processes: 8932 local.
FAILED: Build did NOT complete successfully

Could you please advise?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 14
  • Comments: 36 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I believe the following will fix this issue:

pip install keras_applications==1.0.4 --no-deps
pip install keras_preprocessing==1.0.2 --no-deps

@yifeif any additional info?

You might also need pip install h5py==2.8.0

we should update our installation from sources documentation with this information.

I can confirm that installing the three packages resolves the issue as per this link

I had the same problem during the installation in virtualenv. It worked once I installed

pip install keras_applications==1.0.4 --no-deps pip install keras_preprocessing==1.0.2 --no-deps pip install h5py==2.8.0

outside of the virtual environment.

In my case it was the problem that there are two different versions of packages with - and _ after keras so keras_applications and keras-applications. I was looking at one and TF was requiring the other one. The same goes for keras_preprocessing

You will either need to create the virtualenv with --system-site-packages, or run pip install keras-applications (and other pip install commands) after you activate the virtualenv.

works great, thank you!!