ImportError: cannot import name 'load_dataset' from 'datasets' (unknown location)
Hey,I am new to working with NLP and working through the tutorial. I installed the transformers library and after some trouble everything worked out. Now I tried to install the datasets library, installation went alright (details at end)Now I’m trying to work with it in jupyter notebook. The lineimport datasetsworks out fine, but when I tryfrom datasets import load_datasetI get the error from above. I looked around in this forum and also others and couldn’t find a solution.I am using Python 3.9.12, Pytorch 1.12.0 and Tranformers version 4.22.0.dev0.Any help is appreciated!Details regarding installation:I installed in from source using pip3 inside a virtual environment; put it in the directory from which I also work on my project; checked the installation which is also suggested in the installation “tutorial” and this also worked out
2022-08-09T10:33:30Z
Hi!It’s strange, your code is ok… Did you check if the virtual environment is enabled in the notebook? Can you copy the error log?
2022-08-09T11:30:00Z
Hey, thanks rwheel!I think I enabled the environment, as I included it with (.env is the name of the environment)python -m ipykernel install --user --name=.envand got the acceptionInstalled kernelspec .env in /home/username/.local/share/jupyter/kernels/.envI’m sorry but what do you mean by error log? And where do I find it?
2022-08-09T11:51:49Z
Sorry, I was referring to the error you get when you dofrom datasets import load_datasetAfter including the virtual environment to the jupyter notebook, did you change the kernel to the created env before running the script?
2022-08-10T09:49:22Z
yes I did:/ I really can’t think of anything else to do haha. I deinstalled datasets again and reinstalled it and also double checked it by letting me show all the installed packages but now evenimport datasetsdoesnt work and I get the errorModuleNotFoundError: No module named 'datasets'Is there anything I can do? Could it be a problem that I tried with different environments and they are somehow affecting eachother? Or could I try installing it outside of an environment?
2022-08-10T15:59:43Z
It is very weirdI’ve just replicated the example in a google colab and it works well. So I also think, as you say, that  it could be a problem between the environments…  I work withcondato create and manage my environments, did you try that tool?PS: the code that I tried in google colab is:! pip install datasets

from datasets import load_dataset
2023-04-23T19:20:03Z
HiI have the same problem. I restart the kernel and it’s OK
2023-06-07T07:01:56Z
The same phenomenon happens to me as the questioner I’ve installed everythingdataseterror1764×841 60.4 KB
2023-08-29T10:01:03Z
I also met this problem today and successfully fixed it in my computer. There are two reason I found.First is the path problem. By running codeimport sys
list = sys.path
print(list)we may found that there is no path:EnvPath\lib\site-packages, where save our packages installed by pip command. So what we should do is add the path to system’s search range.For example, my python download packages in the pathE:\program Files (x86)\Python 3.6\Lib\site-packageswhile the system only search the pathD:\Dev\Anaconda\envs\pytorch\lib\site-packages.To solve this problem, we canvisit the pathD:\Dev\Anaconda\envs\pytorch\lib\site-packagesandcreat a txtfile and save the path infomation:E:\program Files (x86)\Python 3.6\Lib\site-packages. After saving the file, change thetxtformat topthformat, likemypath.pth. In this way ,the problem may solved.Second is the filename problem. Change the file name fromdatasets.pyto other name likeimage_datasets.If the problem still exist, please provide more details to try solving together
2023-10-08T13:48:39Z
Sometimes restarting the kernel do the trick. It worked for me.
2024-06-27T08:14:39Z
try to delete the datasets folders from C:\Python310\Lib\site-packagesthen run %pip install -U datasets then restart the kernal .in the last step try to re-run the import cell without running the install step again
2024-10-28T09:54:31Z
I meet this question in the afternoon, after retrieval all the way, and 1 hour consumed, i know the real problem and the reasoning about the problem.The solve step:restart the environmentchange the file name, do not name it like datasets.py or datasets.ipynbGood blogs like:https://blog.csdn.net/whatday/article/details/109333877(this one helps me solved the problem)this huggingface blogPython Circular Import Error Solved | Built In