text: 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.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 9
  • Comments: 49 (23 by maintainers)

Most upvoted comments

So still no prebuilt version for MacOs? Maybe there is straight forward instruction how to do this?

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<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”, }, )

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.

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
        ],
)

I checked and the patch file differs in the version of text that I was using (which is https://github.com/tensorflow/text/archive/refs/tags/v2.9.0.zip). I then tried again with the 2.9 branch which does include the right version of sp.patch but I got other errors. This lead me to try several branches and actually the build succeeded with version 2.10! Many thanks for your help!

To anyone reading that ended up here from suns tutorial, here’s what I did to make it work:

  1. Upgraded to Monterey, not sure if that is necessary but apple lists it as a requirement for metal here.
  2. Use mamba instead of conda, so install mambaforge and replace ‘conda’ with ‘mamba’ in the commands.
  3. Use version 2.10 instead of 2.9. So change “tensorflow-deps==2.9.0” to “tensorflow-deps==2.10” and “tensorflow-macos==2.9.0” to “tensorflow-macos==2.10”. I also changed oss_scripts/configure.sh as per step 5 of the tutorial but I’m not sure if that is necessary. Get the zip from the github branch 2.10 and then follow the rest of the tutorial.

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.