Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed
  TnD0WQEygW8e 2023年11月02日 36 0

E:\Eprogramfiles\Anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py in preload_check() .append(dll_name) if missing: ---> 54"Could not find the DLL(s) %r. TensorFlow requires that these DLLs " "be installed in a directory that is named in your %%PATH%% "

 

Could not find the DLL(s)

 

 

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>

解决方法:

(1) 把 msvcp140_1.dll 复制到path变量中某一个文件夹即可。

(2) 要分辨Python是32位,还是64位;

https://learn.microsoft.com/zh-CN/cpp/windows/latest-supported-vc-redist?view=msvc-170

(安装的时候记得看Python版本,如果是64位的,下载visual studio 2015/2017和2019一定要选择64位的。)

Extract the folders ,Copy the .DLL file to your C:\Windows\System32\ folder. ( 32 bit) Copy the .DLL file to your C:\Windows\SysWOW64\ folder. ( 64 bit)

https://www.dll-files.com/

https://www.dll-files.com/msvcp140_1.dll.html

 

 Windows 是32位,64位;python 是32位,64位?

 

体系结构

链接

说明

ARM64

https://aka.ms/vs/17/release/vc_redist.arm64.exe

最新受支持 ARM64 版本的永久链接

X86

https://aka.ms/vs/17/release/vc_redist.x86.exe

最新受支持 x86 版本的永久链接

X64

https://aka.ms/vs/17/release/vc_redist.x64.exe

最新受支持 x64 版本的永久链接。 X64 可再发行程序包包含 ARM64 和 X64 二进制文件。 当 X64 可再发行程序包安装在 ARM64 设备上时,可以通过此包轻松安装所需的 Visual C++ ARM64 二进制文件。

 

E:\Eprogramfiles\Anaconda3\python.exe

Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 (AMD64)] :: Anaconda, Inc. on win32

 

>>> import platform
>>> platform.architecture()
('64bit', 'WindowsPE')

 

C:\Users\Administrator>E:\Eprogramfiles\Anaconda3\python.exe
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64

 def preload_check():
  """Raises an exception if the environment is not correctly configured.

  Raises:
    ImportError: If the check detects that the environment is not correctly
      configured, and attempting to load the TensorFlow runtime will fail.
  """
  if os.name == "nt":
    # Attempt to load any DLLs that the Python extension depends on before
    # we load the Python extension, so that we can raise an actionable error
    # message if they are not found.
    import ctypes  # pylint: disable=g-import-not-at-top
    if MSVCP_DLL_NAMES in build_info.build_info:
      missing = []
      for dll_name in build_info.build_info[MSVCP_DLL_NAMES].split(","):
        try:          
          ctypes.WinDLL(dll_name)
          print("============",os.getcwd(),dll_name)
        except OSError:
          missing.append(dll_name)
          print("ER=====",os.getcwd(),dll_name)

Could not find the DLL(s)

 

 

 

 

Could not find the DLL(s)

 

 

 

 

Could not find the DLL(s)

 

 

Could not find the DLL(s)

 

Could not find the DLL(s)

 

Jupyter Notebook:

E:\Eprogramfiles\Anaconda3\python.exe
3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)]
sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
RuntimeError: Failed to import transformers.trainer 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

 

I installed tensorflow2.0.0-alpha0 for Python 3.7.2 on Windows 7 SP1. It's importing fine in Jupyter notebook, but when I try to import it in IDLE or the Python interpreter invoked from the command line, I get this error message.

0

I copied msvcp140.dll from one of the subfolders in python37 and pasted it in the main python37 folder (which contains python, pythonw etc files).

 

 

 

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

如何安装transformers

如何安装transformer  transformer

 

1. 首先,需要安装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

 



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
TnD0WQEygW8e