'ModuleNotFoundError: No module named 'keras_preprocessing' tensorflow2.2 with pip
I'm trying to build tensorflow 2.2 from source with the command:
bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.2 --action_env PYTHON_BIN_PATH=/usr/bin/python3.8 //tensorflow/tools/pip_package:build_pip_package
If I build the package I get the error:
ModuleNotFoundError: No module named 'keras_preprocessing'
However, I have Keras-Preprocessing 1.1.0* installed, which should be a correct version.
I know this question is similar to: ModuleNotFoundError: No module named 'keras_preprocessing' but I am, using pip and not conda. How can this be solved with pip?
This is the stacktrace:
/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/ops/random_ops.py:285: SyntaxWarning: "is" with a literal. Did you mean "=="?
minval_is_zero = minval is 0 # pylint: disable=literal-comparison
/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/ops/random_ops.py:286: SyntaxWarning: "is" with a literal. Did you mean "=="?
maxval_is_one = maxval is 1 # pylint: disable=literal-comparison
/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/ops/ragged/ragged_batch_gather_with_default_op.py:84: SyntaxWarning: "is not" with a literal. Did you mean "!="?
if (default_value.shape.ndims is not 0
/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/ops/ragged/ragged_batch_gather_with_default_op.py:85: SyntaxWarning: "is not" with a literal. Did you mean "!="?
and default_value.shape.ndims is not 1):
Traceback (most recent call last):
File "/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 776, in <module>
main()
File "/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/tools/api/generator/create_python_api.py", line 755, in main
importlib.import_module(package)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/keras/datasets/imdb.py", line 25, in <module>
from tensorflow.python.keras.preprocessing.sequence import _remove_long_seq
File "/home/brent/.cache/bazel/_bazel_brent/f717514c870df2340554ff84ed4b3c4d/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/python/keras/api/create_tensorflow.python_api_keras_python_api_gen_compat_v1.runfiles/org_tensorflow/tensorflow/python/keras/preprocessing/__init__.py", line 23, in <module>
import keras_preprocessing
ModuleNotFoundError: No module named 'keras_preprocessing'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/brent/Documents/Projects/BenchmarkRCStrategiesSOTA/tensorflow/tensorflow/python/tools/BUILD:82:1 Executing genrule //tensorflow/python/keras/api:keras_python_api_gen failed (Exit 1)
INFO: Elapsed time: 14402.619s, Critical Path: 406.14s
INFO: 14101 processes: 14101 local.
FAILED: Build did NOT complete successfully
Solution 1:[1]
ok, my guess is that /usr/bin/python3.8 is not the python environment in which you installed keras-preprocessing.
You should reinstall it with pip install and then print the path to your python environment with the command: which python
Then, relaunch the bazel build with the path of your python environment in :PYTHON_BIN_PATH=<result of the which python command>
Solution 2:[2]
You can use dio for communicating with Spotify API.
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 | Benjamin Breton |
| Solution 2 | Hrvoje ?ukman |
