Can't import datasets AttributeError: partially initialized module 'datasets' has no attribute 'utils' (most likely due to a circular import)
State: closed | Author: OPterminator (NONE)
Labels: name: bug

## Describe the bug
A clear and concise description of what the bug is.
Not able to import datasets 
## Steps to reproduce the bug
```python
# Sample code to reproduce the bug
import os
os.environ["WANDB_API_KEY"] = "0" ## to silence warning
import numpy as np
import random
import sklearn
import matplotlib.pyplot as plt
import pandas as pd
import sys
import tensorflow as tf
import plotly.express as px
import transformers
import tokenizers
import nlp as nlp
import utils
import datasets
```

## Expected results
A clear and concise description of the expected results.
import should work normal
## Actual results
Specify the actual results or traceback.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-b3b5b0b62103> in <module>
     13 import nlp as nlp
     14 import utils
---> 15 import datasets

~\anaconda3\lib\site-packages\datasets\__init__.py in <module>
     44 from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
     45 from .info import DatasetInfo, MetricInfo
---> 46 from .inspect import (
     47     get_dataset_config_info,
     48     get_dataset_config_names,

~\anaconda3\lib\site-packages\datasets\inspect.py in <module>
     28 from .download.streaming_download_manager import StreamingDownloadManager
     29 from .info import DatasetInfo
---> 30 from .load import dataset_module_factory, import_main_class, load_dataset_builder, metric_module_factory
     31 from .utils.file_utils import relative_to_absolute_path
     32 from .utils.logging import get_logger

~\anaconda3\lib\site-packages\datasets\load.py in <module>
     53 from .iterable_dataset import IterableDataset
     54 from .metric import Metric
---> 55 from .packaged_modules import (
     56     _EXTENSION_TO_MODULE,
     57     _MODULE_SUPPORTS_METADATA,

~\anaconda3\lib\site-packages\datasets\packaged_modules\__init__.py in <module>
      4 from typing import List
      5 
----> 6 from .csv import csv
      7 from .imagefolder import imagefolder
      8 from .json import json

~\anaconda3\lib\site-packages\datasets\packaged_modules\csv\csv.py in <module>
     13 
     14 
---> 15 logger = datasets.utils.logging.get_logger(__name__)
     16 
     17 _PANDAS_READ_CSV_NO_DEFAULT_PARAMETERS = ["names", "prefix"]

AttributeError: partially initialized module 'datasets' has no attribute 'utils' (most likely due to a circular import)

## Environment info
<!-- You can run the command `datasets-cli env` and copy-and-paste its output below. -->
Copy-and-paste the text below in your GitHub issue.

- `datasets` version: 2.4.0
- Platform: Windows-10-10.0.22000-SP0
- Python version: 3.8.8
- PyArrow version: 9.0.0
- Pandas version: 1.2.4


Comments: Thanks for reporting, @OPterminator.

However, we are not able to reproduce this issue.

There might be 2 reasons why you get this exception:
- Either the name of your local Python file: if it is called  `datasets.py` this could generate a circular import when trying to import the Hugging Face `datasets` library.
  - You could try to rename it and run it again.
- Another cause could be the simultaneous use of the packages `nlp` and `datasets`. Please note that we renamed the Hugging Face `nlp` library to `datasets` more than 2 years ago: they are 2 versions of the same library.
  - Please try to update your script and use only `datasets` (`nlp` name is no longer in use and is out of date).

i am also facing this issue


```
----> 1 import datasets
      3 dataset = datasets.load_dataset("ucberkeley-dlab/measuring-hate-speech", "binary")
      4 df = dataset["train"].to_pandas()

File ~/.pyenv/versions/3.10.9/lib/python3.10/site-packages/datasets/__init__.py:52
     50 from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
     51 from .info import DatasetInfo, MetricInfo
---> 52 from .inspect import (
     53     get_dataset_config_info,
     54     get_dataset_config_names,
     55     get_dataset_infos,
     56     get_dataset_split_names,
     57     inspect_dataset,
     58     inspect_metric,
     59     list_datasets,
     60     list_metrics,
     61 )
     62 from .iterable_dataset import IterableDataset
     63 from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric

File ~/.pyenv/versions/3.10.9/lib/python3.10/site-packages/datasets/inspect.py:30
     28 from .download.streaming_download_manager import StreamingDownloadManager
...
---> 16 logger = datasets.utils.logging.get_logger(__name__)
     19 if datasets.config.PYARROW_VERSION.major >= 7:
     21     def pa_table_to_pylist(table):
```

I am facing the same question. And this happens when i installing `evaluate` package while `jupyter notebook` running. I'm not sure if the error occured because of trying to import the package installed when the notebook is running.  Surpringly when i stop the notebook and rerun, the issue has been solved itself. Hope this will be helpful : )

I also got this error.
It helped me to find the python process and kill it, then restart the kernel and the error disappeared.

> I also got this error. It helped me to find the python process and kill it, then restart the kernel and the error disappeared.

Yes!

> I am facing the same question. And this happens when i installing `evaluate` package while `jupyter notebook` running. I'm not sure if the error occured because of trying to import the package installed when the notebook is running. Surpringly when i stop the notebook and rerun, the issue has been solved itself. Hope this will be helpful : )

Thank you! :)

Yes, i met the same error when import pandas after restarting computers. 
AttributeError: partially initialized module 'pandas' has no attribute '_pandas_parser_CAPI' (most likely due to a circular import)
some think pandas.py file need to be found and delete, i tried but it did not work.
however, restarted the kernel and solved it!!! 
Thanks very much