ImportError: cannot import name 'Dataset'

See original GitHub issue

Environment info

  • transformers version: 4.2.1, datasets : 1.2.1
  • Platform: Linux AI-LAB 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Python version: 3.6.8
  • PyTorch version (GPU?): 1.7.1
  • Tensorflow version (GPU?):
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help

Anyone.

Information

Completely install Transformers + datasets. by pip command

The problem arises when using: When i try to import Lib: from transformers import AutoTokenizer, AutoModel

Error like this:

ImportError                               Traceback (most recent call last)
<ipython-input-2-c6bea6c01ce9> in <module>
----> 1 from transformers import AutoTokenizer, AutoModel

/usr/local/lib/python3.6/dist-packages/transformers/__init__.py in __getattr__(self, name)
   2096             if name == "__version__":
   2097                 return __version__
-> 2098             return super().__getattr__(name)
   2099 
   2100     sys.modules[__name__] = _LazyModule(__name__, _import_structure)

/usr/local/lib/python3.6/dist-packages/transformers/file_utils.py in __getattr__(self, name)
   1463         elif name in self._class_to_module.keys():
   1464             module = self._get_module(self._class_to_module[name])
-> 1465             value = getattr(module, name)
   1466         else:
   1467             raise AttributeError(f"module {self.__name__} has no attribute {name}")

/usr/local/lib/python3.6/dist-packages/transformers/file_utils.py in __getattr__(self, name)
   1462             value = self._get_module(name)
   1463         elif name in self._class_to_module.keys():
-> 1464             module = self._get_module(self._class_to_module[name])
   1465             value = getattr(module, name)
   1466         else:

/usr/local/lib/python3.6/dist-packages/transformers/models/auto/__init__.py in _get_module(self, module_name)
    158 
    159         def _get_module(self, module_name: str):
--> 160             return importlib.import_module("." + module_name, self.__name__)
    161 
    162     sys.modules[__name__] = _LazyModule(__name__, _import_structure)

/usr/lib/python3.6/importlib/__init__.py in import_module(name, package)
    124                 break
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 
    128 

/usr/local/lib/python3.6/dist-packages/transformers/models/auto/modeling_auto.py in <module>
    152 from ..pegasus.modeling_pegasus import PegasusForConditionalGeneration, PegasusModel
    153 from ..prophetnet.modeling_prophetnet import ProphetNetForCausalLM, ProphetNetForConditionalGeneration, ProphetNetModel
--> 154 from ..rag.modeling_rag import (  # noqa: F401 - need to import all RagModels to be in globals() function
    155     RagModel,
    156     RagSequenceForGeneration,

/usr/local/lib/python3.6/dist-packages/transformers/models/rag/modeling_rag.py in <module>
     27 from ...utils import logging
     28 from .configuration_rag import RagConfig
---> 29 from .retrieval_rag import RagRetriever
     30 
     31 

/usr/local/lib/python3.6/dist-packages/transformers/models/rag/retrieval_rag.py in <module>
     37 
     38 if is_datasets_available():
---> 39     from datasets import Dataset, load_dataset, load_from_disk
     40 
     41 if is_faiss_available():

ImportError: cannot import name 'Dataset'

Thanks Nakarin

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
pemagrg1commented, Mar 29, 2022

Upgrading both Transformer and huggingface_hub worked for me.

pip install -U transformers
pip install -U huggingface_hub
2reactions
LysandreJikcommented, Jan 24, 2022

Could you try upgrading huggingface_hub to the latest version?

pip install -U huggingface_hub
Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name 'load_dataset' from 'datasets ...
Hey, I am new to working with NLP and working through the tutorial. I installed the transformers library and after some trouble everything...
Read more >
ImportError: cannot import name 'datasets' from 'fastai'
Hi there, I've been looking all over for similar posts but can't seem to find ... ImportError: cannot import name 'datasets' from 'fastai'....
Read more >
sklearn in Python 3.4 "ImportError: cannot import name ...
Are you trying to use the cluster tutorial on sklearn? from sklearn.cluster import KMeans from sklearn import datasets.
Read more >
ImportError: cannot import name 'AdultDataset' from 'dataset'
I found out: from dataset import AdultDataset. is giving the error below: ImportError: cannot import name 'AdultDataset' from 'dataset' ...
Read more >
ImportError: cannot import name 'KNNImputer' - Kaggle
@psvishnu I updated the scikit-learn library and its working fine for me. Try to restart the kernel, install the updated version first and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found