Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to import tensorflow_text #2

Closed
jbmaxwell opened this issue Apr 26, 2022 · 8 comments
Closed

Error when trying to import tensorflow_text #2

jbmaxwell opened this issue Apr 26, 2022 · 8 comments
Assignees
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed question Further information is requested

Comments

@jbmaxwell
Copy link

jbmaxwell commented Apr 26, 2022

First off, thanks for writing this tutorial!

The process seemed to go okay, but I'm getting an error when trying to import tensorflow_text in python:

>>> import tensorflow_text as text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jbmaxwell/src/text-2.8.2/tensorflow_text/__init__.py", line 20, in <module>
    from tensorflow_text.core.pybinds import tflite_registrar
ImportError: cannot import name 'tflite_registrar' from 'tensorflow_text.core.pybinds' (unknown location)

It seems like a problem with the install.

I tried re-launching my shell session, but then I just get a ModuleNotFoundError: No module named 'tensorflow_text', as if it was never installed. Any idea what might be going on? Is there somewhere in particular I should run the bazel and text installs?

PS -- I'm running macOS 12.3, Xcode 13.2.1, on a 16" MacBook Pro M1 Pro.

@sun1638650145 sun1638650145 self-assigned this Apr 26, 2022
@sun1638650145 sun1638650145 added the question Further information is requested label Apr 26, 2022
@sun1638650145
Copy link
Owner

This error is that you are running directly from the source folder of text.

@jbmaxwell
Copy link
Author

jbmaxwell commented Apr 27, 2022

Well, it doesn't exclusively happen from that folder. If I cd to another folder, start python, and try to import, I get the following:

>>> import tensorflow_text as text
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow_text'
>>> 

Everything seems to go okay during the install, so I'm confused as to why it's not being found...

I see quite a few warnings during the build, like was built for newer macOS version (12.3) than being linked (12.1), but the build does finish.

@jbmaxwell
Copy link
Author

Okay, I got it. Not being super experienced with Python I didn't realize I had to do: pip install tensorflow_text-2.8.2-cp39-cp39-macosx_11_0_arm64.whl to actually install the module. It might be good to finish the tutorial with this step.

Thanks again for the tutorial!

@sun1638650145
Copy link
Owner

sun1638650145 commented Apr 28, 2022

I'm glad you solved your problem. Then, I'll add hints at your suggestion.

@sun1638650145 sun1638650145 added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Apr 28, 2022
@stromal
Copy link

stromal commented Jul 11, 2022

CODE

pip install ./*.whl

ERROR

ERROR: tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl is not a supported wheel on this platform.

@sun1638650145
Copy link
Owner

@stromal According to the tag you did not build an arm64 package. This tutorial does not discuss about intel Mac.

@maurlco
Copy link

maurlco commented Jan 17, 2023

Thank you @sun1638650145 for your tutorial - I am new to python and ML and struggle to import/run tensorflow-text on my M1 macOS.

I followed all the steps (no problem so far) until step 7 :
==> Please do not forget to install the whl file:
==> pip install ./*.whl

(tensorflow-macos) (Projet 4) ➜ text-2.9.0 git:(main) ✗ pip install ./*.whl
result:
zsh: no matches found: ./*.whl

I tried to replace ./*.whl by 'tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl' or 'tensorflow_text-2.8.2-cp39-cp39-macosx_11_0_arm64.whl' to see if it would find something.

(tensorflow-macos) (Projet 4) ➜ Projet 4 git:(main) ✗ pip install tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl
result:
WARNING: Requirement 'tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl' looks like a filename, but the file does not exist ERROR: tensorflow_text-2.9.0-cp38-cp38-macosx_10_9_x86_64.whl is not a supported wheel on this platform.

I guess that I need to download a 'tensorflow-text.whl' file before doing the pip install ./*.whl but don't know where to find it.

### Could you please provide more details for the last STEP 7 ?
Where should I find the whl file ?

Thanks

@sun1638650145
Copy link
Owner

@maurlco You can download the precompiled whl file I provided from here. In fact, step 7 is the least important step, it just prompts you to install the whl file. I suggest you provide me with more information, and check your own toolchain for version errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants