Как мне установить тензор_текста? - PullRequest
2 голосов
/ 17 февраля 2020

Я пытаюсь воспроизвести записную книжку в многоязычном универсальном кодировщике Google . Однако, загрузив необходимые библиотеки как tensorflow_text:

%%capture
#@title Setup Environment
# Install the latest Tensorflow version.
!pip3 install tensorflow_text

или

!python -m pip install tensorflow_text

И я получаю в 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'

Я попытался установить его с python -m pip install tensorflow-text, но это дало мне:

(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.

Я также попробовал 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

И 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.

Я нахожусь Windows 10

Ответы [ 2 ]

1 голос
/ 17 февраля 2020

Это должно работать: pip install tensorflow-text

0 голосов
/ 31 марта 2020

ЧАСТЬ 1: УСТАНОВКА TENSORFLOW

Чтобы установить тензор потока с Anaconda, сделайте следующее:

Шаг 1

Загрузите Anaconda с здесь и установите его.

Шаг 2

Откройте Anaconda Prompt от имени администратора

Шаг 3

Создайте виртуальную среду conda с именем tennsflow_env с помощью следующая команда:

C:\> conda create -n tensorflow_env python=3.7

Шаг 4

Активировать среду conda

C:\> activate tensorflow_env

Теперь ваша подсказка должна измениться на

(tensorflow_env) C:\>

Шаг 5

Установите TensorFlow в среду Anaconda

(tensorflow_env) C:\> conda install -c conda-forge tensorflow

Шаг 6 (необязательно)

Убедитесь, что вы установили Anaconda

(tensorflow_env) C:\>python
>>> import tensorflow
>>> print(tensorflow. __version__)

Шаги ниже описана эта статья .
Так я успешно установил TensforFlow на свое устройство.

======================= ==============================

ЧАСТЬ 2: Исправление предупреждения

ECHO "WARNING: Did not find VS in registry or in VS140COMNTOOLS env var - your compiler may not work"

Как мне удалось решить это в Windows

1) Установить параметр для просмотра скрытых файлов

2) Go в этом месте

C:\ProgramData\Anaconda3\envs\tensorflow_env\etc\conda\activate.d

3) Удалить пакетный файл с именем "vs2015_compiler_vars"

=========

Как я думаю, чтобы решить эту проблему в Linux

Найдите файл с именем "vs2015_compiler_vars" и удалите его.

Как сказано в комментарии на другой вопрос от @Arpan, файл может быть найден на

$CONDAHOME/etc/conda/activate.d
...