遇见了以下报错

Traceback (most recent call last):
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\import_utils.py", line 434, in _get_module
    return importlib.import_module('.' + module_name, self.__name__)
  File "D:\ANACONDA\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\ANACONDA\lib\site-packages\modelscope\preprocessors\nlp\token_classification_preprocessor.py", line 16, in <module>
    from .transformers_tokenizer import NLPTokenizer
  File "D:\ANACONDA\lib\site-packages\modelscope\preprocessors\nlp\transformers_tokenizer.py", line 7, in <module>
    from transformers import AutoTokenizer
ModuleNotFoundError: No module named 'transformers'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\ANACONDA\lib\site-packages\modelscope\pipelines\builder.py", line 140, in pipeline
    return build_pipeline(cfg, task_name=task)
  File "D:\ANACONDA\lib\site-packages\modelscope\pipelines\builder.py", line 57, in build_pipeline
    cfg, PIPELINES, group_key=task_name, default_args=default_args)
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\registry.py", line 184, in build_from_cfg
    LazyImportModule.import_module(sig)
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\import_utils.py", line 458, in import_module
    importlib.import_module(module_name)
  File "D:\ANACONDA\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\ANACONDA\lib\site-packages\modelscope\pipelines\nlp\word_segmentation_pipeline.py", line 13, in <module>
    from modelscope.preprocessors import (
  File "<frozen importlib._bootstrap>", line 1032, in _handle_fromlist
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\import_utils.py", line 418, in __getattr__
    value = getattr(module, name)
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\import_utils.py", line 417, in __getattr__
    module = self._get_module(self._class_to_module[name])
  File "D:\ANACONDA\lib\site-packages\modelscope\utils\import_utils.py", line 438, in _get_module
    f'(look up to see its traceback):\n{e}') from e
RuntimeError: Failed to import modelscope.preprocessors.nlp.token_classification_preprocessor because of the following error (look up to see its traceback):
No module named 'transformers'

这个报错显示在导入transformers模块时发生了错误,可能是因为缺少了该模块。

为了解决这个问题,需要安装transformers库。可以尝试以下方法:

  1. 使用pip安装transformers

    pip install transformers
    
  2. 确保安装的transformers版本与你的代码兼容。你可以指定特定的版本进行安装,例如:

    pip install transformers==4.12.0
    

确保在执行以上步骤之前,你的网络连接正常,并且Anaconda环境或虚拟环境已激活。如果问题仍然存在,请确保你的安装环境和依赖项都正确配置,并尝试进行进一步的故障排除。
在这里插入图片描述

GitHub 加速计划 / tra / transformers
63
5
下载
huggingface/transformers: 是一个基于 Python 的自然语言处理库,它使用了 PostgreSQL 数据库存储数据。适合用于自然语言处理任务的开发和实现,特别是对于需要使用 Python 和 PostgreSQL 数据库的场景。特点是自然语言处理库、Python、PostgreSQL 数据库。
最近提交(Master分支:4 个月前 )
e5fd865e * initial setup for ggml.py * initial setup of GGUFGemma2Converter class * Add gemma2 model to gguf.md doc * Partial work on GGUF_TENSOR_MAPPING * initial setup of GGUF_TENSOR_MAPPING for Gemma2 * refactor: rename GemmaConvert class to GemmaConverter for naming consistency * feat: complete gemma2 tensor mapping implementation * feat: add initial implementation of GGUFGemmaConverter * feat: complete GGUFGemmaConverter implementation * feat: add test code for gemma2 * refactor: minor code cleanup * refactor: minor code cleanup * fix: resolve suggestions * Update tests/quantization/ggml/test_ggml.py Co-authored-by: Isotr0py <2037008807@qq.com> --------- Co-authored-by: Isotr0py <2037008807@qq.com> 1 天前
1fe2d53d 1 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐