Skip to content

Could not import module 'AutoTokenizer'. Are this object's requirements defined correctly? #40089

@octavianBordeanu

Description

@octavianBordeanu

System Info

Who can help?

@ArthurZucker @itazap

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

from transformers import AutoTokenizer


ModuleNotFoundError Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2045, in _LazyModule.getattr(self, name)
2044 try:
-> 2045 module = self._get_module(self._class_to_module[name])
2046 value = getattr(module, name)

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2075, in _LazyModule._get_module(self, module_name)
2074 except Exception as e:
-> 2075 raise e

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2073, in _LazyModule._get_module(self, module_name)
2072 try:
-> 2073 return importlib.import_module("." + module_name, self.name)
2074 except Exception as e:

File /usr/local/lib/python3.10/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1050, in _gcd_import(name, package, level)

File :1027, in find_and_load(name, import)

File :992, in find_and_load_unlocked(name, import)

File :241, in _call_with_frames_removed(f, *args, **kwds)

File :1050, in _gcd_import(name, package, level)

File :1027, in find_and_load(name, import)

File :1004, in find_and_load_unlocked(name, import)

ModuleNotFoundError: No module named 'transformers.models.ipynb_checkpoints'

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

ModuleNotFoundError Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2045, in _LazyModule.getattr(self, name)
2044 try:
-> 2045 module = self._get_module(self._class_to_module[name])
2046 value = getattr(module, name)

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2075, in _LazyModule._get_module(self, module_name)
2074 except Exception as e:
-> 2075 raise e

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2073, in _LazyModule._get_module(self, module_name)
2072 try:
-> 2073 return importlib.import_module("." + module_name, self.name)
2074 except Exception as e:

File /usr/local/lib/python3.10/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1050, in _gcd_import(name, package, level)

File :1027, in find_and_load(name, import)

File :1006, in find_and_load_unlocked(name, import)

File :688, in _load_unlocked(spec)

File :883, in exec_module(self, module)

File :241, in _call_with_frames_removed(f, *args, **kwds)

File ~/.local/lib/python3.10/site-packages/transformers/models/encoder_decoder/configuration_encoder_decoder.py:20
19 from ...utils import logging
---> 20 from ..auto import AutoConfig
23 logger = logging.get_logger(name)

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2048, in _LazyModule.getattr(self, name)
2047 except (ModuleNotFoundError, RuntimeError) as e:
-> 2048 raise ModuleNotFoundError(
2049 f"Could not import module '{name}'. Are this object's requirements defined correctly?"
2050 ) from e
2052 elif name in self._modules:

ModuleNotFoundError: Could not import module 'AutoConfig'. Are this object's requirements defined correctly?

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

ModuleNotFoundError Traceback (most recent call last)
File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2045, in _LazyModule.getattr(self, name)
2044 try:
-> 2045 module = self._get_module(self._class_to_module[name])
2046 value = getattr(module, name)

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2075, in _LazyModule._get_module(self, module_name)
2074 except Exception as e:
-> 2075 raise e

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2073, in _LazyModule._get_module(self, module_name)
2072 try:
-> 2073 return importlib.import_module("." + module_name, self.name)
2074 except Exception as e:

File /usr/local/lib/python3.10/importlib/init.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1050, in _gcd_import(name, package, level)

File :1027, in find_and_load(name, import)

File :1006, in find_and_load_unlocked(name, import)

File :688, in _load_unlocked(spec)

File :883, in exec_module(self, module)

File :241, in _call_with_frames_removed(f, *args, **kwds)

File ~/.local/lib/python3.10/site-packages/transformers/models/auto/tokenization_auto.py:37
29 from ...utils import (
30 cached_file,
31 extract_commit_hash,
(...)
35 logging,
36 )
---> 37 from ..encoder_decoder import EncoderDecoderConfig
38 from .auto_factory import _LazyAutoMapping

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2048, in _LazyModule.getattr(self, name)
2047 except (ModuleNotFoundError, RuntimeError) as e:
-> 2048 raise ModuleNotFoundError(
2049 f"Could not import module '{name}'. Are this object's requirements defined correctly?"
2050 ) from e
2052 elif name in self._modules:

ModuleNotFoundError: Could not import module 'EncoderDecoderConfig'. Are this object's requirements defined correctly?

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

ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from transformers import AutoTokenizer, AutoModelForCausalLM

File ~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:2048, in _LazyModule.getattr(self, name)
2046 value = getattr(module, name)
2047 except (ModuleNotFoundError, RuntimeError) as e:
-> 2048 raise ModuleNotFoundError(
2049 f"Could not import module '{name}'. Are this object's requirements defined correctly?"
2050 ) from e
2052 elif name in self._modules:
2053 try:

ModuleNotFoundError: Could not import module 'AutoTokenizer'. Are this object's requirements defined correctly?

Expected behavior

The same error arises even if transformers are upgraded to the latest version. Importing transformers by itself does not throw any errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions