python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"
Microsoft Visual C++ Redistributable is not installed, this may lead to the DLL load failure.
It can be downloaded at https://aka.ms/vs/16/release/vc_redist.x64.exe
Traceback (most recent call last):
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\utils\import_utils.py", line 1172, in _get_module
return importlib.import_module("." + module_name, self.__name__)
File "E:\Eprogramfiles\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\pipelines\__init__.py", line 44, in <module>
from .audio_classification import AudioClassificationPipeline
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\pipelines\audio_classification.py", line 21, in <
module>
from .base import PIPELINE_INIT_ARGS, Pipeline
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\pipelines\base.py", line 36, in <module>
from ..modelcard import ModelCard
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\modelcard.py", line 48, in <module>
from .training_args import ParallelMode
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\training_args.py", line 30, in <module>
from .trainer_utils import (
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\trainer_utils.py", line 47, in <module>
import tensorflow as tf
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
self_check.preload_check()
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 54, in preload
_check
raise ImportError(
ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a dire
ctory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ R
edistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.co
m/help/2977003/the-latest-supported-visual-c-downloads
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 1039, in _handle_fromlist
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\utils\import_utils.py", line 1162, in __getattr__
module = self._get_module(self._class_to_module[name])
File "E:\Eprogramfiles\Anaconda3\lib\site-packages\transformers\utils\import_utils.py", line 1174, in _get_module
raise RuntimeError(
RuntimeError: Failed to import transformers.pipelines because of the following error (look up to see its traceback)
:
Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads
PS E:\Eprogramfiles\Anaconda3\Scripts>
解决方法:把 msvcp140_1.dll 复制到path变量中某一个文件夹即可。
==========================================
如何安装transformers
如何安装transformer transformer1. 首先,需要安装Python。建议安装3.6及以上版本的Python。
2. 按照transformers官方文档的要求,需要额外安装PyTorch或TensorFlow。具体选择哪一个取决于您的需求。建议先安装PyTorch或TensorFlow,然后再安装transformers。
3. 打开终端,输入以下命令安装transformers:
pip install transformers
4. 安装完成后,您可以尝试运行以下命令测试是否成功安装:
python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"
如果输出结果为:
[{'label': 'POSITIVE', 'score': 0.9998704795837402}]
则说明已经成功安装并使用transformers进行了情感分析。
REF
https://www.5axxw.com/questions/simple/1lzxjc
标签:transformers,Anaconda3,these,Eprogramfiles,Could,dll,File,import,line From: https://www.cnblogs.com/emanlee/p/17442056.html