我在试着复制notebook on Google Multilingual Universal Encoder。但是,通过将所需的库下载为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
发布于 2020-02-18 03:31:20
这应该是可行的:pip install tensorflow-text
发布于 2021-02-05 05:34:11
在版本2.4.1 (发布于2020年12月)之前,无法通过pip安装tensorflow-text
(作为tensorflow_text
导入)。
对于Windows,你现在可以这样做:pip install tensorflow-text
,它应该可以工作。
发布于 2020-03-31 17:11:12
第1部分:安装TENSORFLOW
要使用Anaconda安装tensorflow,请执行以下操作:
第一步
从here下载Anaconda并安装它。
第二步
以管理员身份打开蟒蛇提示符
第三步
使用以下命令创建一个名为tensorflow_env的conda虚拟环境:
C:\> conda create -n tensorflow_env python=3.7
第四步
激活conda环境
C:\> activate tensorflow_env
现在您的提示符应该更改为
(tensorflow_env) C:\>
第五步
将TensorFlow安装到蟒蛇环境中
(tensorflow_env) C:\> conda install -c conda-forge tensorflow
第6步(可选)
检查您是否已安装Anaconda
(tensorflow_env) C:\>python
>>> import tensorflow
>>> print(tensorflow. __version__)
下面描述的步骤来自this article。
这就是我在设备上成功安装TensforFlow的方法。
==============================================
第2部分:修复警告
ECHO "WARNING: Did not find VS in registry or in VS140COMNTOOLS env var - your compiler may not work"
我是如何在Windows中解决这个问题的
1)设置查看隐藏文件的选项
2)转到此位置
C:\ProgramData\Anaconda3\envs\tensorflow_env\etc\conda\activate.d
3)删除名为vs2015_compiler_vars的批处理文件
=========
我如何在Linux中解决这个问题?
找到名为"vs2015_compiler_vars“的文件并将其删除。
正如@Arpan在another question上的评论中建议的那样,该文件可以在以下位置找到
$CONDAHOME/etc/conda/activate.d
https://stackoverflow.com/questions/60267745
复制相似问题