Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TFPreTrainedModel.prepare_tf_dataset() gives ImportError: Datasets module not found; but it is installed and usable (load_dataset() works)

See original GitHub issue

System Info

Google Colab CPU Instance

  • transformers version: 4.23.1
  • Platform: Linux-5.10.133±x86_64-with-Ubuntu-18.04-bionic
  • Python version: 3.7.15
  • Huggingface_hub version: 0.10.1
  • PyTorch version (GPU?): 1.12.1+cu113 (False)
  • Tensorflow version (GPU?): 2.9.2 (False)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: Yes (However, the issue occurs even when not using parallel setup)

Who can help?



  • The official example scripts
  • My own modified scripts


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


I was trying to follow along this nb from the notebooks repo This is the Colab link of my attempt, with the outputs (and the error)

Expected behavior

Detect that the Datasets package is present and use it as required.

Maybe there’s a really silly mistake I’m making but I really cannot figure out what it could be and I couldn’t find any similar results online.

Thanks in advance!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

Rocketknight1commented, Oct 20, 2022

Wait, this is just me being stupid. This is caused by us caching _datasets_available in import_utils. As a result, this will always happen if you import and use transformers classes before you pip install datasets because this will cache a value of False until you restart your runtime. There’s no bug to fix here in transformers - @swap-10 you just need to install datasets before importing transformers!

Rocketknight1commented, Oct 21, 2022

Closing this issue now that we’ve added the user warnings about restarting the runtime

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: No module named 'tensorflow_datasets ... - GitHub
I have installed rocm and rocm suppoted tensor flow, Observed the below error Traceback (most recent call last): File ".
Read more >
ImportError: No module named datasets - Stack Overflow
when i am writing this in python sript. import tensorflow as tf from datasets import dataset_utils slim = tf.contrib.slim. But i ...
Read more >
Fix ModuleNotFoundError No Module Named Tensorflow ...
... No Module Named Tensorflow Python Import Error ( If Installed / If ... pip2 list and pip3 list to find out which...
Read more >
datasets.load — datasets 1.0.2 documentation - Hugging Face
Version]``): if specified, the module will be loaded from the datasets ... for DownloadConfig() which will override the attributes in download_config if ......
Read more >
Why am I getting ImportError: No module named tensorflow?
In the above image, this error is occuring because I am not in the correct Python virtual environment. Notice The words “Python 3”...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found