Reputation: 3306
I'm trying to reproduce the notebook on Google Multilingual Universal Encoder. However by downloading the necessary libraries as tensorflow_text
:
%%capture
#@title Setup Environment
# Install the latest Tensorflow version.
!pip3 install tensorflow_text
or
!python -m pip install tensorflow_text
And I get in jupyter:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-48-399dd4157896> in <module>
8 import tensorflow.compat.v2 as tf
9 import tensorflow_hub as hub
---> 10 from tensorflow_text import SentencepieceTokenizer
11 import sklearn.metrics.pairwise
12
ModuleNotFoundError: No module named 'tensorflow_text'
I tried to install it with python -m pip install tensorflow-text
, but it gave me:
(seg_env) C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>python -m pip install tensorflow-text
Collecting tensorflow-text
ERROR: Could not find a version that satisfies the requirement tensorflow-text (from versions: none)
ERROR: No matching distribution found for tensorflow-text
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I also tried conda install -c conda-forge tensorflow
(seg_env) C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment> conda install -c conda-forge tensorflow
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>set "KERAS_BACKEND="
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>python C:\Users\antoi\.conda\envs\seg_env\etc\keras\load_config.py 1>temp.txt
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>set /p KERAS_BACKEND= 0<temp.txt
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>del temp.txt
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>python -c "import keras" 1>nul 2>&1
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>if errorlevel 1 (
ver 1>nul
set "KERAS_BACKEND=theano"
python -c "import keras" 1>nul 2>&1
)
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>SET DISTUTILS_USE_SDK=1
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>SET MSSdk=1
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>SET platform=
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>IF /I [AMD64] == [amd64] set "platform=true"
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>IF /I [] == [amd64] set "platform=true"
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>if defined platform (set "VSREGKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0" ) ELSE (set "VSREGKEY=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0" )
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>for /F "skip=2 tokens=2,*" %A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0" /v InstallDir') do SET "VSINSTALLDIR=%B"
ERROR: The system was unable to find the specified registry key or value.
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>if "" == "" (set "VSINSTALLDIR=" )
C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation\sentiment>if "" == "" (
ECHO "WARNING: Did not find VS in registry or in VS140COMNTOOLS env var - your compiler may not work"
GOTO End
)
"WARNING: Did not find VS in registry or in VS140COMNTOOLS env var - your compiler may not work"
The system cannot find the batch label specified - End
(seg_env) C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation>python -m pip list | findstr tensorflow
tensorflow 2.1.0
tensorflow-estimator 2.1.0
And python:
(seg_env) C:\Users\antoi\Documents\Programming\Covent Garden\Segmentation>python
Python 3.6.7 (default, Dec 6 2019, 07:03:06) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
I'm on Windows 10
Upvotes: 13
Views: 42318
Reputation: 11
I was getting a similar error
ERROR: Could not find a version that satisfies the requirement tensorflow-text (from versions: none)
ERROR: No matching distribution found for tensorflow-text
Then I figured out that my python version does not support the tensorflow-text version I was trying to install. The Python version I was using (3.11.7) is likely the reason why I was having trouble installing tensorflow-text. As of now, tensorflow-text doesn't support Python 3.11. It's compatible with Python versions 3.6 to 3.9 and in some cases, 3.10.
Hence I created a new environment in Conda with a lower Python version
conda create -n tf39-env python=3.9
conda activate tf39-env
After installing in new environment I started getting a new error-
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tensorflow-intel 2.17.0 requires keras>=3.2.0, but you have keras 2.10.0 which is incompatible.
tensorflow-intel 2.17.0 requires protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3, but you have protobuf 3.19.6 which is incompatible.
tensorflow-intel 2.17.0 requires tensorboard<2.18,>=2.17, but you have tensorboard 2.10.1 which is incompatible.
Then I reinstalled the packages with correct versions.
pip install tensorflow==2.17.0
pip install keras==3.2.0
pip install protobuf==4.21.5
pip install tensorboard==2.17.0
Then I installed Spyder in the new environment
conda install spyder
I also checked latest version from https://pypi.org/project/tensorflow-text. It was 2.17.0
pip install tensorflow-text
I had to upgrade the spyder kernel separately in my new environment
conda install spyder-kernels=2.4
Now my issue is resolved Screenshot for successfull import
Upvotes: 1
Reputation: 109
I had TensorFlow
version 2.5 and used the below command and it worked.
pip install -U tensorflow-text==2.5
Upvotes: 3
Reputation: 353
The installation of tensorflow-text
(imported as tensorflow_text
) through pip was not possible for Windows until version 2.4.1 (released Dec 2020).
For Windows, you can now do: pip install tensorflow-text
and it should work.
Upvotes: 1
Reputation: 2599
This is a known issue with the packages provided by the TensorFlow-Text project that apparently re-surfaces from time to time. See Issue 89 and Issue 291 in their GitHub.
You can either wait until this is resolved (again), or try to build the package from source.
Upvotes: 0
Reputation: 2370
In order to install tensorflow with Anaconda do the following:
Download Anaconda from here and install it.
Open Anaconda Prompt as Administrator
Create a conda virtual environment named tensorflow_env with the following command:
C:\> conda create -n tensorflow_env python=3.7
Activate the conda environment
C:\> activate tensorflow_env
Now your prompt should change to
(tensorflow_env) C:\>
Install TensorFlow into your Anaconda environment
(tensorflow_env) C:\> conda install -c conda-forge tensorflow
Check that you have installed Anaconda
(tensorflow_env) C:\>python
>>> import tensorflow
>>> print(tensorflow. __version__)
The steps described below are from this article.
This was the way I successfully installed TensforFlow on my device.
==============================================
ECHO "WARNING: Did not find VS in registry or in VS140COMNTOOLS env var - your compiler may not work"
C:\ProgramData\Anaconda3\envs\tensorflow_env\etc\conda\activate.d
=========
Find the file named "vs2015_compiler_vars" and delete it.
As sugested in a comment at another question by @Arpan, the file may be found at
$CONDAHOME/etc/conda/activate.d
Upvotes: 0