AttributeError: module 'huggingface_hub' has no attribute 'hf_api'
MEMBER
Hi @arymbe, thanks for reporting.

Unfortunately, I'm not able to reproduce your problem.

Could you please write the complete stack trace? That way we will be able to see which package originates the exception.
2022-04-07T08:20:46Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1091285033
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5BC7Ap
https://api.github.com/repos/huggingface/datasets/issues/comments/1091285033/reactions
2022-04-07T08:20:46Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1091285033
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
NONE
Hello, thank you for your fast replied. this is the complete error that I got

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

Input In [27], in <module>
----> 1 from datasets import load_dataset

venv/lib/python3.8/site-packages/datasets/__init__.py:39, in <module>
     37 from .arrow_dataset import Dataset, concatenate_datasets
     38 from .arrow_reader import ReadInstruction
---> 39 from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
     40 from .combine import interleave_datasets
     41 from .dataset_dict import DatasetDict, IterableDatasetDict

venv/lib/python3.8/site-packages/datasets/builder.py:40, in <module>
     32 from .arrow_reader import (
     33     HF_GCP_BASE_URL,
     34     ArrowReader,
   (...)
     37     ReadInstruction,
     38 )
     39 from .arrow_writer import ArrowWriter, BeamWriter
---> 40 from .data_files import DataFilesDict, sanitize_patterns
     41 from .dataset_dict import DatasetDict, IterableDatasetDict
     42 from .features import Features

venv/lib/python3.8/site-packages/datasets/data_files.py:297, in <module>
    292     except FileNotFoundError:
    293         raise FileNotFoundError(f"The directory at {base_path} doesn't contain any data file") from None
    296 def _resolve_single_pattern_in_dataset_repository(
--> 297     dataset_info: huggingface_hub.hf_api.DatasetInfo,
    298     pattern: str,
    299     allowed_extensions: Optional[list] = None,
    300 ) -> List[PurePath]:
    301     data_files_ignore = FILES_TO_IGNORE
    302     fs = HfFileSystem(repo_info=dataset_info)

AttributeError: module 'huggingface_hub' has no attribute 'hf_api'
2022-04-07T08:31:14Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1091309962
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5BDBGK
https://api.github.com/repos/huggingface/datasets/issues/comments/1091309962/reactions
2022-04-07T08:31:14Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1091309962
https://avatars.githubusercontent.com/u/4567991?v=4
https://api.github.com/users/arymbe/events{/privacy}
https://api.github.com/users/arymbe/followers
https://api.github.com/users/arymbe/following{/other_user}
https://api.github.com/users/arymbe/gists{/gist_id}
https://github.com/arymbe
arymbe
MDQ6VXNlcjQ1Njc5OTE=
https://api.github.com/users/arymbe/orgs
https://api.github.com/users/arymbe/received_events
https://api.github.com/users/arymbe/repos
https://api.github.com/users/arymbe/starred{/owner}{/repo}
https://api.github.com/users/arymbe/subscriptions
User
https://api.github.com/users/arymbe
public
MEMBER
This is weird... It is long ago that the package `huggingface_hub` has a submodule called `hf_api`.

Maybe you have a problem with your installed `huggingface_hub`...

Could you please try to update it?
```shell
pip install -U huggingface_hub
```
2022-04-07T09:21:19Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1091410204
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5BDZkc
https://api.github.com/repos/huggingface/datasets/issues/comments/1091410204/reactions
2022-04-07T09:22:43Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1091410204
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
NONE
Yap, I've updated several times. Then, I've tried numeral combination of datasets and huggingface_hub versions. However, I think your point is right that there is a problem with my huggingface_hub installation. I'll try another way to find the solution. I'll update it later when I get the solution. Thank you :)
2022-04-07T09:33:15Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1091427459
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5BDdyD
https://api.github.com/repos/huggingface/datasets/issues/comments/1091427459/reactions
2022-04-07T09:36:51Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1091427459
https://avatars.githubusercontent.com/u/4567991?v=4
https://api.github.com/users/arymbe/events{/privacy}
https://api.github.com/users/arymbe/followers
https://api.github.com/users/arymbe/following{/other_user}
https://api.github.com/users/arymbe/gists{/gist_id}
https://github.com/arymbe
arymbe
MDQ6VXNlcjQ1Njc5OTE=
https://api.github.com/users/arymbe/orgs
https://api.github.com/users/arymbe/received_events
https://api.github.com/users/arymbe/repos
https://api.github.com/users/arymbe/starred{/owner}{/repo}
https://api.github.com/users/arymbe/subscriptions
User
https://api.github.com/users/arymbe
public
MEMBER
I'm sorry I can't reproduce your problem.

Maybe you could try to create a new Python virtual environment and install all dependencies there from scratch. You can use either:
- Python venv: https://docs.python.org/3/library/venv.html
- or conda venv (if you are using conda): https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
2022-04-07T09:37:43Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1091432775
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5BDfFH
https://api.github.com/repos/huggingface/datasets/issues/comments/1091432775/reactions
2022-04-07T09:37:43Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1091432775
https://avatars.githubusercontent.com/u/8515462?v=4
https://api.github.com/users/albertvillanova/events{/privacy}
https://api.github.com/users/albertvillanova/followers
https://api.github.com/users/albertvillanova/following{/other_user}
https://api.github.com/users/albertvillanova/gists{/gist_id}
https://github.com/albertvillanova
albertvillanova
MDQ6VXNlcjg1MTU0NjI=
https://api.github.com/users/albertvillanova/orgs
https://api.github.com/users/albertvillanova/received_events
https://api.github.com/users/albertvillanova/repos
https://api.github.com/users/albertvillanova/starred{/owner}{/repo}
https://api.github.com/users/albertvillanova/subscriptions
User
https://api.github.com/users/albertvillanova
public
NONE
Facing the same issue.

Response from `pip show datasets`
```
Name: datasets
Version: 1.15.1
Summary: HuggingFace community-driven open-source library of datasets
Home-page: https://github.com/huggingface/datasets
Author: HuggingFace Inc.
Author-email: thomas@huggingface.co
License: Apache 2.0
Location: /usr/local/lib/python3.8/dist-packages
Requires: aiohttp, dill, fsspec, huggingface-hub, multiprocess, numpy, packaging, pandas, pyarrow, requests, tqdm, xxhash
Required-by: lm-eval
```

Response from `pip show huggingface_hub`

```
Name: huggingface-hub
Version: 0.8.1
Summary: Client library to download and publish models, datasets and other repos on the huggingface.co hub
Home-page: https://github.com/huggingface/huggingface_hub
Author: Hugging Face, Inc.
Author-email: julien@huggingface.co
License: Apache
Location: /usr/local/lib/python3.8/dist-packages
Requires: filelock, packaging, pyyaml, requests, tqdm, typing-extensions
Required-by: datasets
```

response from `datasets-cli env`

```
Traceback (most recent call last):
  File "/usr/local/bin/datasets-cli", line 5, in <module>
    from datasets.commands.datasets_cli import main
  File "/usr/local/lib/python3.8/dist-packages/datasets/__init__.py", line 37, in <module>
    from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
  File "/usr/local/lib/python3.8/dist-packages/datasets/builder.py", line 44, in <module>
    from .data_files import DataFilesDict, _sanitize_patterns
  File "/usr/local/lib/python3.8/dist-packages/datasets/data_files.py", line 120, in <module>
    dataset_info: huggingface_hub.hf_api.DatasetInfo,
  File "/usr/local/lib/python3.8/dist-packages/huggingface_hub/__init__.py", line 105, in __getattr__
    raise AttributeError(f"No {package_name} attribute {name}")
AttributeError: No huggingface_hub attribute hf_api
```
2022-06-23T16:20:39Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1164617793
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5FaqhB
https://api.github.com/repos/huggingface/datasets/issues/comments/1164617793/reactions
2022-06-23T16:33:14Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1164617793
https://avatars.githubusercontent.com/u/1976061?v=4
https://api.github.com/users/roots-ai/events{/privacy}
https://api.github.com/users/roots-ai/followers
https://api.github.com/users/roots-ai/following{/other_user}
https://api.github.com/users/roots-ai/gists{/gist_id}
https://github.com/roots-ai
roots-ai
MDQ6VXNlcjE5NzYwNjE=
https://api.github.com/users/roots-ai/orgs
https://api.github.com/users/roots-ai/received_events
https://api.github.com/users/roots-ai/repos
https://api.github.com/users/roots-ai/starred{/owner}{/repo}
https://api.github.com/users/roots-ai/subscriptions
User
https://api.github.com/users/roots-ai
public
NONE
A workaround: 
I changed lines around Line 125 in `__init__.py` of `huggingface_hub` to something like
```
__getattr__, __dir__, __all__ = _attach(
    __name__,
    submodules=['hf_api'],
```
and it works ( which gives `datasets` direct access to `huggingface_hub.hf_api` ).
2022-06-23T22:11:15Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1164941361
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5Fb5gx
https://api.github.com/repos/huggingface/datasets/issues/comments/1164941361/reactions
2022-06-23T22:11:15Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1164941361
https://avatars.githubusercontent.com/u/6436708?v=4
https://api.github.com/users/xxchenxx/events{/privacy}
https://api.github.com/users/xxchenxx/followers
https://api.github.com/users/xxchenxx/following{/other_user}
https://api.github.com/users/xxchenxx/gists{/gist_id}
https://github.com/xxchenxx
xxchenxx
MDQ6VXNlcjY0MzY3MDg=
https://api.github.com/users/xxchenxx/orgs
https://api.github.com/users/xxchenxx/received_events
https://api.github.com/users/xxchenxx/repos
https://api.github.com/users/xxchenxx/starred{/owner}{/repo}
https://api.github.com/users/xxchenxx/subscriptions
User
https://api.github.com/users/xxchenxx
public
NONE
I was getting the same issue. After trying a few versions, following combination worked for me.
dataset==2.3.2
huggingface_hub==0.7.0

In another environment, I just installed latest repos from pip through `pip install -U transformers datasets tokenizers evaluate`, resulting in following versions. This also worked. Hope it helps someone. 

datasets-2.3.2 evaluate-0.1.2 huggingface-hub-0.8.1 responses-0.18.0 tokenizers-0.12.1 transformers-4.20.1
2022-06-27T17:56:47Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1167684851
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5FmXTz
https://api.github.com/repos/huggingface/datasets/issues/comments/1167684851/reactions
2022-06-27T17:56:47Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1167684851
https://avatars.githubusercontent.com/u/1519077?v=4
https://api.github.com/users/MaveriQ/events{/privacy}
https://api.github.com/users/MaveriQ/followers
https://api.github.com/users/MaveriQ/following{/other_user}
https://api.github.com/users/MaveriQ/gists{/gist_id}
https://github.com/MaveriQ
MaveriQ
MDQ6VXNlcjE1MTkwNzc=
https://api.github.com/users/MaveriQ/orgs
https://api.github.com/users/MaveriQ/received_events
https://api.github.com/users/MaveriQ/repos
https://api.github.com/users/MaveriQ/starred{/owner}{/repo}
https://api.github.com/users/MaveriQ/subscriptions
User
https://api.github.com/users/MaveriQ
public
NONE
For layoutlm_v3 finetune
datasets-2.3.2 evaluate-0.1.2 huggingface-hub-0.8.1 responses-0.18.0 tokenizers-0.12.1 transformers-4.12.5
2022-07-20T01:50:01Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1189715317
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5G6Z11
https://api.github.com/repos/huggingface/datasets/issues/comments/1189715317/reactions
2022-07-20T01:50:01Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1189715317
https://avatars.githubusercontent.com/u/13639445?v=4
https://api.github.com/users/moyans/events{/privacy}
https://api.github.com/users/moyans/followers
https://api.github.com/users/moyans/following{/other_user}
https://api.github.com/users/moyans/gists{/gist_id}
https://github.com/moyans
moyans
MDQ6VXNlcjEzNjM5NDQ1
https://api.github.com/users/moyans/orgs
https://api.github.com/users/moyans/received_events
https://api.github.com/users/moyans/repos
https://api.github.com/users/moyans/starred{/owner}{/repo}
https://api.github.com/users/moyans/subscriptions
User
https://api.github.com/users/moyans
public
NONE
(For layoutlmv3 fine-tuning) In my case, modifying `requirements.txt` as below worked.

- python = 3.7

```
datasets==2.3.2
evaluate==0.1.2
huggingface-hub==0.8.1
response==0.5.0
tokenizers==0.10.1
transformers==4.12.5
seqeval==1.2.2
deepspeed==0.5.7
tensorboard==2.7.0
seqeval==1.2.2
sentencepiece
timm==0.4.12
Pillow
einops
textdistance
shapely
```
2022-07-22T03:03:25Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1192131145
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5HDnpJ
https://api.github.com/repos/huggingface/datasets/issues/comments/1192131145/reactions
2022-07-22T03:03:25Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1192131145
https://avatars.githubusercontent.com/u/71648550?v=4
https://api.github.com/users/jaylnne/events{/privacy}
https://api.github.com/users/jaylnne/followers
https://api.github.com/users/jaylnne/following{/other_user}
https://api.github.com/users/jaylnne/gists{/gist_id}
https://github.com/jaylnne
jaylnne
MDQ6VXNlcjcxNjQ4NTUw
https://api.github.com/users/jaylnne/orgs
https://api.github.com/users/jaylnne/received_events
https://api.github.com/users/jaylnne/repos
https://api.github.com/users/jaylnne/starred{/owner}{/repo}
https://api.github.com/users/jaylnne/subscriptions
User
https://api.github.com/users/jaylnne
public
NONE
> For layoutlm_v3 finetune datasets-2.3.2 evaluate-0.1.2 huggingface-hub-0.8.1 responses-0.18.0 tokenizers-0.12.1 transformers-4.12.5

GOOD!! Thanks!
2022-07-28T16:44:04Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1198389519
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps5HbfkP
https://api.github.com/repos/huggingface/datasets/issues/comments/1198389519/reactions
2022-07-28T16:44:04Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1198389519
https://avatars.githubusercontent.com/u/27748841?v=4
https://api.github.com/users/pogevip/events{/privacy}
https://api.github.com/users/pogevip/followers
https://api.github.com/users/pogevip/following{/other_user}
https://api.github.com/users/pogevip/gists{/gist_id}
https://github.com/pogevip
pogevip
MDQ6VXNlcjI3NzQ4ODQx
https://api.github.com/users/pogevip/orgs
https://api.github.com/users/pogevip/received_events
https://api.github.com/users/pogevip/repos
https://api.github.com/users/pogevip/starred{/owner}{/repo}
https://api.github.com/users/pogevip/subscriptions
User
https://api.github.com/users/pogevip
public
NONE
I encountered the same issue where the problem is the absence of the 'scipy' library.
To solve this open your terminal or command prompt and run the following command to install 'scipy':   pip install scipy .
Restart the kernel and rerun the cell and it will work.

2024-02-15T14:10:36Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-1946173825
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps50AEGB
https://api.github.com/repos/huggingface/datasets/issues/comments/1946173825/reactions
2024-02-15T14:11:35Z
https://api.github.com/repos/huggingface/datasets/issues/comments/1946173825
https://avatars.githubusercontent.com/u/95570391?v=4
https://api.github.com/users/mohamedayari1/events{/privacy}
https://api.github.com/users/mohamedayari1/followers
https://api.github.com/users/mohamedayari1/following{/other_user}
https://api.github.com/users/mohamedayari1/gists{/gist_id}
https://github.com/mohamedayari1
mohamedayari1
U_kgDOBbJJ1w
https://api.github.com/users/mohamedayari1/orgs
https://api.github.com/users/mohamedayari1/received_events
https://api.github.com/users/mohamedayari1/repos
https://api.github.com/users/mohamedayari1/starred{/owner}{/repo}
https://api.github.com/users/mohamedayari1/subscriptions
User
https://api.github.com/users/mohamedayari1
public
NONE
> I was getting the same issue. After trying a few versions, following combination worked for me. dataset==2.3.2 huggingface_hub==0.7.0
> 
> In another environment, I just installed latest repos from pip through `pip install -U transformers datasets tokenizers evaluate`, resulting in following versions. This also worked. Hope it helps someone.
> 
> datasets-2.3.2 evaluate-0.1.2 huggingface-hub-0.8.1 responses-0.18.0 tokenizers-0.12.1 transformers-4.20.1



> I was getting the same issue. After trying a few versions, following combination worked for me. dataset==2.3.2 huggingface_hub==0.7.0
> 
> In another environment, I just installed latest repos from pip through `pip install -U transformers datasets tokenizers evaluate`, resulting in following versions. This also worked. Hope it helps someone.
> 
> datasets-2.3.2 evaluate-0.1.2 huggingface-hub-0.8.1 responses-0.18.0 tokenizers-0.12.1 transformers-4.20.1

I face with the same issue. After using your approach I solve the issue.Thank you very much.
`pip install -U datasets`
2024-05-07T09:24:34Z
https://github.com/huggingface/datasets/issues/4117#issuecomment-2097847759
https://api.github.com/repos/huggingface/datasets/issues/4117
IC_kwDODunzps59Cp3P
https://api.github.com/repos/huggingface/datasets/issues/comments/2097847759/reactions
2024-05-07T09:24:34Z
https://api.github.com/repos/huggingface/datasets/issues/comments/2097847759
https://avatars.githubusercontent.com/u/146308065?v=4
https://api.github.com/users/chichitutu/events{/privacy}
https://api.github.com/users/chichitutu/followers
https://api.github.com/users/chichitutu/following{/other_user}
https://api.github.com/users/chichitutu/gists{/gist_id}
https://github.com/chichitutu
chichitutu
U_kgDOCLh74Q
https://api.github.com/users/chichitutu/orgs
https://api.github.com/users/chichitutu/received_events
https://api.github.com/users/chichitutu/repos
https://api.github.com/users/chichitutu/starred{/owner}{/repo}
https://api.github.com/users/chichitutu/subscriptions
User
https://api.github.com/users/chichitutu
public
## Describe the bug
Could you help me please. I got this following error.

AttributeError: module 'huggingface_hub' has no attribute 'hf_api'

## Steps to reproduce the bug
when I imported the datasets

# Sample code to reproduce the bug
from datasets import list_datasets, load_dataset, list_metrics, load_metric

## Environment info
<!-- You can run the command `datasets-cli env` and copy-and-paste its output below. -->
- `datasets` version: 2.0.0
- Platform: macOS-12.3-x86_64-i386-64bit
- Python version: 3.8.9
- PyArrow version: 7.0.0
- Pandas version: 1.3.5
- Huggingface-hub: 0.5.0
- Transformers: 4.18.0

Thank you in advance.