tensorflow / probability

Probabilistic reasoning and statistical analysis in TensorFlow
https://www.tensorflow.org/probability/
Apache License 2.0
4.27k stars 1.11k forks source link

probability 0.17.0 doesn't build on macOS with error ModuleNotFoundError: No module named 'absl' #1594

Open essandess opened 2 years ago

essandess commented 2 years ago

I'm attempting to update tensor flow_probability for MacPorts.

Version 0.17.0 fails to build on macOS with error:

File "/opt/local/var/macports/build/_opt_local_ports_python_py-tensorflow-probability/py310-tensorflow-probability/work/bazel_build/4191c7127d7c33c5af5f12aa8dc0d886/sandbox/processwrapper-sandbox/5/execroot/tensorflow_probability/bazel-out/darwin-opt-exec-2B5CBBC6/bin/tensorflow_probability/substrates/meta/rewrite.runfiles/tensorflow_probability/tensorflow_probability/substrates/meta/rewrite.py", line 20, in <module>
from absl import app
ModuleNotFoundError: No module named 'absl'

(Full log file: main.log.gz)

This import issue may be caused by the fact that there is no __init__.py file in the directory ./tensorflow_probability/substrates/meta.

I've tried adding my own __init__.py file to the source directory, but bazel appears to be downloading its own source, and I'm uncertain how to address or work around this issue.

See also #539.

gl-yziquel commented 5 months ago

I tried to install to install tensorflow from source using the following command:

bazelisk build --copt=O3 --copt=-march-native :pip_pkg

I also get, on ubuntu, the same error:

mini-me@virtucon ~/h/c/probability (main)> bazelisk build --copt=O3 --copt=-march-native :pip_pkg                       
WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
/home/mini-me/home/cellar/probability/tools/bazel.rc                                                                                                                                                                                          
Starting local Bazel server and connecting to it...                                                                    
INFO: Analyzed target //:pip_pkg (150 packages loaded, 5196 targets configured).                                       
ERROR: /home/mini-me/home/cellar/probability/tensorflow_probability/python/experimental/util/BUILD:35:27: Executing genrule //tensorflow_probability/python/experimental/util:rewrite___init___py_jax failed: (Exit 1): bash failed: error exe
cuting Genrule command (from target //tensorflow_probability/python/experimental/util:rewrite___init___py_jax) /bin/bash -c ... (remaining 1 argument skipped)                                                                                

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging           
Traceback (most recent call last):                                                                                     
  File "/home/mini-me/.cache/bazel/_bazel_yziquel/7d4a81cb29695bb226fe1e3c59e64ae7/sandbox/linux-sandbox/3/execroot/_main/bazel-out/k8-opt-exec-ST-d57f47055a04/bin/tensorflow_probability/substrates/meta/rewrite.runfiles/_main/tensorflow_p
robability/substrates/meta/rewrite.py", line 20, in <module>                                                                                                                                                                                  
    from absl import app                                                                                               
ModuleNotFoundError: No module named 'absl'

I do not know how all this fits in MacPorts, but this is what I get from source with Ubuntu.

I have the absl module installed from the source abseil-py git repository. In a pyenv virtual environment. It seems bazel doesn't pick up the pyenv virtual environment infrastructure.

So. Two paths: 1. random tinkering till it works 2. getting into the nitty gritty of bazel.