'ImportError: No module named absl.flags

I am trying to build from source using the command bazel run tensorboard -- --logdir path/to/logs as shown in the README but I keep getting the following error:

ERROR: 
(local directory)/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/BUILD:115:8: Executing genrule //tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin:generate_dtypes failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
Traceback (most recent call last):
  File "(local directory)/sandbox/darwin-sandbox/944/execroot/org_tensorflow_tensorboard/bazel-out/darwin-opt-exec-50AE0418/bin/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/extract_dtypes_from_python.runfiles/org_tensorflow_tensorboard/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/extract_dtypes_from_python.py", line 21, in <module>
    from tensorboard.compat.tensorflow_stub import dtypes
  File "(local directory)/sandbox/darwin-sandbox/944/execroot/org_tensorflow_tensorboard/bazel-out/darwin-opt-exec-50AE0418/bin/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/extract_dtypes_from_python.runfiles/org_tensorflow_tensorboard/tensorboard/compat/tensorflow_stub/__init__.py", line 25, in <module>
    from . import app  # noqa
  File "(local directory)/sandbox/darwin-sandbox/944/execroot/org_tensorflow_tensorboard/bazel-out/darwin-opt-exec-50AE0418/bin/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/extract_dtypes_from_python.runfiles/org_tensorflow_tensorboard/tensorboard/compat/tensorflow_stub/app.py", line 21, in <module>
    from . import flags
  File "(local directory)/sandbox/darwin-sandbox/944/execroot/org_tensorflow_tensorboard/bazel-out/darwin-opt-exec-50AE0418/bin/tensorboard/plugins/debugger_v2/tf_debugger_v2_plugin/extract_dtypes_from_python.runfiles/org_tensorflow_tensorboard/tensorboard/compat/tensorflow_stub/flags.py", line 25, in <module>
    from absl.flags import *  # pylint: disable=wildcard-import
ImportError: No module named absl.flags

I tried installing absl-py via pip as well as uninstalling and reinstalling it but can't seem to get past this issue. How do I fix this problem?



Solution 1:[1]

In my case, I was launching my command via the bash script absl-py is python3, but my script was called python instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SherylHohman