ImportError: cannot import name 'get_session' from 'huggingface_hub'
Author: yangzhipeng1108
Pull request: no
Labels: name: bug

### System Info

 transformers==4.38.1 huggingface-hub==0.21.3

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

Traceback (most recent call last):
  File "/root/llama/llama2-fine-tuning/main.py", line 19, in <module>
    from transformers import (
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/transformers/__init__.py", line 26, in <module>
    from . import dependency_versions_check
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/transformers/dependency_versions_check.py", line 16, in <module>
    from .utils.versions import require_version, require_version_core
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/transformers/utils/__init__.py", line 18, in <module>
    from huggingface_hub import get_full_repo_name  # for backward compatibility
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/huggingface_hub/__init__.py", line 379, in __getattr__
    submod = importlib.import_module(submod_path)
  File "/root/miniconda3/envs/ds/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/huggingface_hub/hf_api.py", line 50, in <module>
    from ._commit_api import (
  File "/root/miniconda3/envs/ds/lib/python3.10/site-packages/huggingface_hub/_commit_api.py", line 17, in <module>
    from huggingface_hub import get_session
ImportError: cannot import name 'get_session' from 'huggingface_hub' (/root/miniconda3/envs/ds/lib/python3.10/site-packages/huggingface_hub/__init__.py)

### Expected behavior

from transformers import (
    AutoModelForCausalLM,
    SchedulerType,
    default_data_collator,
    get_scheduler,
)

Comments:
Hi @yangzhipeng1108, thanks for raising an issue! 

I'm unable to replicate this error with transformers==4.38.1 and huggingface-hub==0.21.3. I'd suggest trying to reinstall the libraries, and ensuring your python and pip path are aligned, such that the library versions being run in your environment match those being installed by pip. 

> Hi @yangzhipeng1108, thanks for raising an issue!
> 
> I'm unable to replicate this error with transformers==4.38.1 and huggingface-hub==0.21.3. I'd suggest trying to reinstall the libraries, and ensuring your python and pip path are aligned, such that the library versions being run in your environment match those being installed by pip.

It's happening for me on 4.39.0.

@MrBeeMovie I'm unable to replicate this on 4.39.0

```py
In [1]: from transformers import __version__

In [2]: print(__version__)
4.39.0

In [3]: from huggingface_hub import __version__

In [4]: print(__version__)
0.21.3

In [5]: from transformers import (
   ...: AutoModelForCausalLM,
   ...: SchedulerType,
   ...: default_data_collator,
   ...: get_scheduler,
   ...: )
```

Could you run the same an confirm the versions in your environment? 

> @MrBeeMovie I'm unable to replicate this on 4.39.0
> 
> ```python
> In [1]: from transformers import __version__
> 
> In [2]: print(__version__)
> 4.39.0
> 
> In [3]: from huggingface_hub import __version__
> 
> In [4]: print(__version__)
> 0.21.3
> 
> In [5]: from transformers import (
>    ...: AutoModelForCausalLM,
>    ...: SchedulerType,
>    ...: default_data_collator,
>    ...: get_scheduler,
>    ...: )
> ```
> 
> Could you run the same an confirm the versions in your environment?

I apologize it is an error with a different library on top of transformers for me.

@MrBeeMovie can you tell us what library is that? Having the same issue here...

had the same issue but it was fixed using transformers-4.39.2