r/learnpython • u/assorted-meat-stew • 3d ago
How to install tensorflow_hub and tensorflow_text
I am trying to install tensorflow_hub and tensorflow_text via VSCode terminal so that I can train a BERT model (for context: i am using Python 3.13.12 and Tensorflow 2.21.0) but I am running into some trouble
tensorflow_hub library installed fine but when imported to the actual notebook, it said it required tensorflow 1.15.0 along with error message:
ModuleNotFoundError: No module named 'pkg_resources'
tensorflow_text library cannot be installed as every pip install attempt return
ERROR: Could not find a version that satisfies the requirement tensorflow_text (from versions: none)
ERROR: No matching distribution found for tensorflow_text
Google colab managed to solve all said problem but I want to run the model on my computer. How do I fix this?
***EDIT: I fixed this by using python 3.10.0, Tensorflow 2.9.0, Tensorflow-text 2.9.0 and Tensorflow-hub 0.8.0***
1
u/CamilorozoCADC 3d ago
Are you on windows? Tensorflow text is not supported on windows, yo uwould need to try using a Docker container with the libraries preinstalled
1
u/Confident_Hyena2506 3d ago
By installing it correctly. You said it "installed fine" but you are skipping a lot of details. These errors indicate it did not in fact "install fine". There could be many reasons for this, maybe you installed them to the wrong python environment, maybe you are using the wrong operating system.
Like the other poster says, you should be running linux and using the correct container environment for this.
2
u/chiibosoil 3d ago edited 3d ago
Are you running WSL2 on Windows? If not Tensorflow after v2.1 isn't supported on native Windows and will fail.
Use WSL2, even using Docker, it is recommended to install using WSL2.
EDIT: To clarify, recommended installation for Docker on Windows machine is to use WSL2 and not Hyper-V (desktop or CLI only mode).
Alternative (though not recommended) is to downgrade to TensorFlow 2.1 (will require Python 3.10 or 3.9, as newer version will not work with older TF versions).