ERROR: Could not find a version that satisfies the requirement tensorflow_text (from versions: none)
I am using macOS version Monterey on my MI Air and for some reasons I can't install tensorflow text even though I installed tensorflow. When I run pip3 install tensorflow_text on terminal it says:
ERROR: Could not find a version that satisfies the requirement tensorflow_text (from versions: none)
ERROR: No matching distribution found for tensorflow_text
I have also tried using pip3 install tensorflow-text but the result is same. Is there any other way I can install this? Please help as I am very new to python. Regards.
We currently do not have a prebuilt pip package for M1s. Our release infra is tied to core tensorflow, so it will remain this way until they provide an option too. See #654
That said, we do have targets for building it yourself. View #756 for a healthy discussion on getting this working.
Regarding your failure:
++ sed -i 's/project_version = '\''REPLACE_ME'\''/project_version = '\''2.6.0'\''/' oss_scripts/pip_package/setup.nightly.py
sed: 1: "oss_scripts/pip_package ...": invalid command code o
The command looks different from what is checked in. The double quotes have been translated to single quotes, etc. Did you run some replacement utility over the files?
Regarding your failure:
++ sed -i 's/project_version = '\''REPLACE_ME'\''/project_version = '\''2.6.0'\''/' oss_scripts/pip_package/setup.nightly.py sed: 1: "oss_scripts/pip_package ...": invalid command code oThe command looks different from what is checked in. The double quotes have been translated to single quotes, etc. Did you run some replacement utility over the files?
No, I did this as per the Installation section. I cloned the repo and when I run this command ./oss_scripts/run_build.sh after, this output is what I get. There are no .whl files generated.
Can you look at that file and make sure it mirrors what is here? https://github.com/tensorflow/text/blob/master/oss_scripts/prepare_tf_dep.sh
In particular, look at the types of quotes used. Maybe replace the file manually if possible. The point of this script is to make certain that tf text is building against the version of tensorflow you have installed.
moving discussion here from https://github.com/tensorflow/text/pull/756
so far:
script stalls at sed (can potentially be fixed with -e or ' ')
next fail is at grep -> issue is grep version AND not seeing git version for tensorflow python -c 'import tensorflow as tf; print(tf.__git_version__)' returns unknown
@yulsa @yuyuan20 it looks like there are two issues.
- sed commands are not running correctly
- tf.git_version is not displaying
The point of this file is to make certain you are building tf text against the same version of tf that you have installed. However, it looks like tensorflow-macos does not populate the git_version variable, and since you are not doing a custom build of TF and building against nightly, you should be able to use the default that is set in the branch.
Thus, you can simply remove the prepare_tf_dep.sh line from the build script and I expect you will be fine.
@yulsa @yuyuan20 it looks like there are two issues.
- sed commands are not running correctly
- tf.git_version is not displaying
The point of this file is to make certain you are building tf text against the same version of tf that you have installed. However, it looks like tensorflow-macos does not populate the git_version variable, and since you are not doing a custom build of TF and building against nightly, you should be able to use the default that is set in the branch.
Thus, you can simply remove the prepare_tf_dep.sh line from the build script and I expect you will be fine.
@broken
just tried that. commented out # source oss_scripts/prepare_tf_dep.sh in the build script, and the result fails to build:
maybe there is a way to find the git version manually? can't seem to find anywhere...
retried everything from scratch (recloned git, only change -> comment the source oss_scripts/prepare_tf_dep.sh ub build script. still failed:
I'm in the same spot.
Try updating this file starting at line 48.
/private/var/tmp/_bazel_<yourname>/55d65c43790f28395233053bd8c3ccae/external/local_config_cc/BUILD
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"darwin|compiler": ":cc-compiler-darwin",
"darwin_arm64|compiler": ":cc-compiler-darwin", # <--- new
"darwin": ":cc-compiler-darwin",
"darwin_arm64": ":cc-compiler-darwin", # <--- new
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
},
)
This takes me past that error but onto a new one.
what's the new error?
A couple things to confirm:
- Building on TF Text branch 2.7. This has the WORKSPACE set for TF v2.7.x which has worked for others, and 2.7.0 is the latest version of tensorflow-macos.
- Using bazel version 4.2.1. Normally we used 3.7.2 for builds on that branch, but from a different thread, that version doesn't exist so you would have to build it yourself which is troublesome.
ps. FYI; I saw that legacyai shared their built wheel here on the previous PR. I have no idea of the authenticity package, so typical 'use at your own risk' disclaimer.
the first time I ran the script, was prompted to use Bazel 4.2.2, not sure if makes any difference, but that's the one I configured. do you mean should change it to 3.7.2 to run the script?
No. 4.2.2 should be good. I must be misremembering and 3.7.2 was for tf text 2.6.x and below.
@yulsa @yuyuan20 it looks like there are two issues.
- sed commands are not running correctly
- tf.git_version is not displaying
The point of this file is to make certain you are building tf text against the same version of tf that you have installed. However, it looks like tensorflow-macos does not populate the git_version variable, and since you are not doing a custom build of TF and building against nightly, you should be able to use the default that is set in the branch.
Thus, you can simply remove the prepare_tf_dep.sh line from the build script and I expect you will be fine.
Did it and now it's a new error (the complete log is a bit long so I am just stating a portion of it).
++ SHARED_LIBRARY_NAME=-ltensorflow_framework.2
++ is_macos
++ [[ darwin == \d\a\r\w\i\n ]]
++ SHARED_LIBRARY_NAME=libtensorflow_framework.dylib
++ is_windows
++ [[ darwin =~ msys_nt*|mingw*|cygwin*|uwin* ]]
++ export LD_LIBRARY_PATH=:/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow
++ LD_LIBRARY_PATH=:/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow
++ write_action_env_to_bazelrc TF_HEADER_DIR /opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow/include
++ write_to_bazelrc 'build --action_env TF_HEADER_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow/include"'
++ echo 'build --action_env TF_HEADER_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow/include"'
++ write_action_env_to_bazelrc TF_SHARED_LIBRARY_DIR /opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow
++ write_to_bazelrc 'build --action_env TF_SHARED_LIBRARY_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow"'
++ echo 'build --action_env TF_SHARED_LIBRARY_DIR="/opt/homebrew/Caskroom/miniforge/base/envs/ml-env/lib/python3.9/site-packages/tensorflow"'
++ write_action_env_to_bazelrc TF_SHARED_LIBRARY_NAME libtensorflow_framework.dylib
++ write_to_bazelrc 'build --action_env TF_SHARED_LIBRARY_NAME="libtensorflow_framework.dylib"'
++ echo 'build --action_env TF_SHARED_LIBRARY_NAME="libtensorflow_framework.dylib"'
++ write_action_env_to_bazelrc TF_CXX11_ABI_FLAG 0
++ write_to_bazelrc 'build --action_env TF_CXX11_ABI_FLAG="0"'
++ echo 'build --action_env TF_CXX11_ABI_FLAG="0"'
+ bazel build --enable_runfiles oss_scripts/pip_package:build_pip_package
Starting local Bazel server and connecting to it...
DEBUG: /private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/third_party/repo.bzl:109:14:
Warning: skipping import of repository 'icu' because it already exists.
DEBUG: /private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/third_party/repo.bzl:109:14:
Warning: skipping import of repository 'pybind11' because it already exists.
ERROR: /private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/local_config_cc/BUILD:48:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'darwin_arm64'
INFO: Repository com_google_absl instantiated at:
/Users/yuyuan/Desktop/ml-env/text/WORKSPACE:97:14: in <toplevel>
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/tensorflow/workspace2.bzl:1082:28: in workspace
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/tensorflow/workspace2.bzl:58:9: in _initialize_third_party
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/third_party/absl/workspace.bzl:14:20: in repo
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/third_party/repo.bzl:113:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/org_tensorflow/third_party/repo.bzl:66:35: in <toplevel>
INFO: Repository com_google_sentencepiece instantiated at:
/Users/yuyuan/Desktop/ml-env/text/WORKSPACE:18:13: in <toplevel>
Repository rule http_archive defined at:
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
INFO: Repository icu instantiated at:
/Users/yuyuan/Desktop/ml-env/text/WORKSPACE:5:13: in <toplevel>
Repository rule http_archive defined at:
/private/var/tmp/_bazel_yuyuan/afe558054884c73ef4e344c4ac2630cb/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: Analysis of target '//oss_scripts/pip_package:build_pip_package' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed
INFO: Elapsed time: 5.088s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (39 packages loaded, 458 targets c\
onfigured)
Fetching @local_config_tf; fetching
You are erroring on the bazel build command, so you are building the package. It looks like you ran across the error mentioned above about the missing toolchain. You can try the solution above (https://github.com/tensorflow/text/issues/823#issuecomment-1030305965) or remove mentions of using a toolchain in the .bazelrc file or configure.sh file (and rerun it to write out a new .bazelrc). Then run bazel build oss_scripts/pip_package:build_pip_package again.
I was able to build and install tensorflow_text (.whl) for my Apple Macbook Air with the M1 processor following the discussion on this issue by making the following two changes as detailed above:-
- commented out # source oss_scripts/prepare_tf_dep.sh in the build script as above.
- /private/var/tmp/bazel
/55d65c43790f28395233053bd8c3ccae/external/local_config_cc/BUILD
cc_toolchain_suite( name = "toolchain", toolchains = { "darwin|compiler": ":cc-compiler-darwin", "darwin_arm64|compiler": ":cc-compiler-darwin", # <--- new "darwin": ":cc-compiler-darwin", "darwin_arm64": ":cc-compiler-darwin", # <--- new "armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a", "armeabi-v7a": ":cc-compiler-armeabi-v7a", }, )
Hello. Successfully installed tensorflow_text (with an underscore _ not hyphen -). Followed steps by @sun1638650145 here and @edloper here and @andrewdunkel https://github.com/tensorflow/text/issues/823#issuecomment-1030305965.
Device is: MacBook Pro with M1 pro chip - macOS 12.2.1
Hello,
following exactly the instructions above (python 3.9) I keep getting a compiler error that I don't know how to interpret/resolve.
ERROR: /private/var/tmp/_bazel_XXXXX/03c196188fbb5dc38e3a61a403354856/external/com_google_sentencepiece/BUILD.bazel:51:11: Compiling src/normalizer.cc failed: (Exit 1): cc_wrapper.sh failed: error executing command external/local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics ... (remaining 70 arguments skipped)
external/com_google_sentencepiece/src/normalizer.cc:25:10: error: module: @com_google_sentencepiece//:sentencepiece_processor does not depend on a module exporting 'third_party/darts_clone/darts.h'
#include "third_party/darts_clone/darts.h"
^
1 error generated.
Target //oss_scripts/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
Platform: M1 Pro with Monterey (12.4)
If anyone has an idea where this might come from, any help is greatly appreciated.
Try adding this line at the bottom of : https://github.com/tensorflow/text/blob/master/third_party/sentencepiece/BUILD
...
"@com_google_absl//absl/strings",
"@darts_clone", # < --- new line here
],
)
Thanks you very much for trying to solve this issue! However, neither adding the dependency, nor deleting the entire /private/var/tmp/_bazel_XXXX directory solved that issue.
I also observed the same error for absl/strings, which was obscured by mostly failing on the darts_clone module before reaching the other error. If I compile multiple times, either one of those errors appear.
here is the other error message:
error: module @com_google_sentencepiece//:sentencepiece_processor does not depend on a module exporting 'absl/strings/str_format.h'
P.S. It's weird that I appear to be the only one having this issue. Did anyone else manage to compile using bazel 5.1.1 on an M1 MacBook?
Are you compiling using the most recent commit of branch 2.9? The most recent commit changes configure.sh to download the correct version of .bazelrc and .bazelversion from TF. For 2.9, this is bazel version 5.0.0 and not 5.1.1. The .bazelrc file may have differences as well.
@broken Isn't the version of bazel used by text now the same as tf? tf 2.9 uses bazel 5.1.1.
@raemisch I use bazel 5.1.1, but I used tensorflow-macos 2.9.0 at first, and later updated the tutorial to use 2.9.2 (the latest version of tensorflow is 2.9.1, but I feel that there should be no impact here, as long as the major version is the same).
@raemisch I can confirm that this is happening to me as well on an M1. Exactly the same two imports.
(I can't compile master or the tag v2.9.0)
@broken Isn't the version of
bazelused bytextnow the same astf?tf 2.9usesbazel 5.1.1.
Yes, but for the version TF used on that branch. TF 2.9 uses 5.0.0 - https://github.com/tensorflow/tensorflow/blob/r2.9/.bazelversion
We specify those versions in our branched configure.sh now too - https://github.com/tensorflow/text/blob/2.9/oss_scripts/configure.sh#L64
If you are able to compile fine on 5.1.1 it's not that issue then. It was somewhat a shot in the dark since they were hitting the issue and nobody else.
Looking at this more, the build does seem incomplete. I think the added dep still needs to happen, and then the sp.patch should rewrite those imports to "include/darts.h" instead of third_party. I'll work on a PR for that today.
I believe this should fix it. https://github.com/tensorflow/text/pull/972 You can try cherry-picking it in, or wait until tomorrow and we should be able to have it tested and push it out assuming it doesn't break anything else.
This change has now been cherry-picked into branch 2.9