Huggingface Hub version increased causing import error
Author: harveyz0
Pull request: no
Labels: name: bug

### System Info

python-transformers  4.56.2-1
python-huggingface-hub  1:1.0.1-1 
Python 3.13.7

I'm on Arch Linux with hugging face and transformers installed from the AUR.

If I do the version bump in the `dependency_versions_table.py` then I can get the `transformers env` to run

```
- `transformers` version: 4.56.2
- Platform: Linux-6.12.56-1-lts-x86_64-with-glibc2.42
- Python version: 3.13.7
- Huggingface_hub version: 1.0.1
- Safetensors version: 0.6.2
- Accelerate version: not installed
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.9.0 (CUDA)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA RTX 6000 Ada Generation
```

### 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

Run `import transformers` anywhere. I tried going into `dependency_versions_table.py` and just bumping the version but then I get a different error from the SentenceTransformer code I'm trying to run.

```python
>>> import transformers
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    import transformers
  File "/usr/lib/python3.13/site-packages/transformers/__init__.py", line 27, in <module>
    from . import dependency_versions_check
  File "/usr/lib/python3.13/site-packages/transformers/dependency_versions_check.py", line 57, in <module>
    require_version_core(deps[pkg])
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/transformers/utils/versions.py", line 117, in require_version_core
    return require_version(requirement, hint)
  File "/usr/lib/python3.13/site-packages/transformers/utils/versions.py", line 111, in require_version
    _compare_versions(op, got_ver, want_ver, requirement, pkg, hint)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/transformers/utils/versions.py", line 44, in _compare_versions
    raise ImportError(
        f"{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}"
    )
ImportError: huggingface-hub>=0.34.0,<1.0 is required for a normal functioning of this module, but found huggingface-hub==1.0.1.
Try: `pip install transformers -U` or `pip install -e '.[dev]'` if you're working with git main
```
Error after version bump
```python
>>> t = SentenceTransformer("nomic-ai/nomic-embed-code", device="cuda")
Loading checkpoint shards: 100%|██████████████████████████████████████████████████████| 6/6 [00:00<00:00,  8.65it/s]
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/huggingface_hub/utils/_http.py", line 550, in hf_raise_for_status
    response.raise_for_status()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/httpx/_models.py", line 829, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'https://huggingface.co/api/models/nomic-ai/nomic-embed-code/tree/main/additional_chat_templates?recursive=false&expand=false'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<python-input-7>", line 1, in <module>
    t = SentenceTransformer("nomic-ai/nomic-embed-code", device="cuda")
  File "/usr/lib/python3.13/site-packages/sentence_transformers/SentenceTransformer.py", line 327, in __init__
    modules, self.module_kwargs = self._load_sbert_model(
                                  ~~~~~~~~~~~~~~~~~~~~~~^
        model_name_or_path,
        ^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
        config_kwargs=config_kwargs,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/sentence_transformers/SentenceTransformer.py", line 2305, in _load_sbert_model                                                                                                07:08:01 [3/276]
    module = module_class.load(
        model_name_or_path,
    ...<11 lines>...
        backend=self.backend,
    )
  File "/usr/lib/python3.13/site-packages/sentence_transformers/models/Transformer.py", line 365, in load
    return cls(model_name_or_path=model_name_or_path, **init_kwargs)
  File "/usr/lib/python3.13/site-packages/sentence_transformers/models/Transformer.py", line 102, in __init__
    self.tokenizer = AutoTokenizer.from_pretrained(
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        tokenizer_name_or_path if tokenizer_name_or_path is not None else model_name_or_path,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        cache_dir=cache_dir,
        ^^^^^^^^^^^^^^^^^^^^
        **tokenizer_args,
        ^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/transformers/models/auto/tokenization_auto.py", line 1125, in from_pretrained
    return tokenizer_class.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/transformers/tokenization_utils_base.py", line 2012, in from_pretrained
    for template in list_repo_templates(
                    ~~~~~~~~~~~~~~~~~~~^
        pretrained_model_name_or_path,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        cache_dir=cache_dir,
        ^^^^^^^^^^^^^^^^^^^^
    ):
    ^
  File "/usr/lib/python3.13/site-packages/transformers/utils/hub.py", line 169, in list_repo_templates
    for entry in list_repo_tree(
                 ~~~~~~~~~~~~~~^
        repo_id=repo_id,
        ^^^^^^^^^^^^^^^^
    ...<2 lines>...
        recursive=False,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/lib/python3.13/site-packages/huggingface_hub/hf_api.py", line 3080, in list_repo_tree
    for path_info in paginate(path=tree_url, headers=headers, params={"recursive": recursive, "expand": expand}):
                     ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/huggingface_hub/utils/_pagination.py", line 37, in paginate
    hf_raise_for_status(r)
    ~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/lib/python3.13/site-packages/huggingface_hub/utils/_http.py", line 564, in hf_raise_for_status
    raise _format(RemoteEntryNotFoundError, message, response) from e
huggingface_hub.errors.RemoteEntryNotFoundError: 404 Client Error. (Request ID: Root=1-6905ea11-200d6a394af082017e2bc2af;3b81023e-1bd5-4133-861f-7c1bb98a0071)

Entry Not Found for url: https://huggingface.co/api/models/nomic-ai/nomic-embed-code/tree/main/additional_chat_templates?recursive=false&expand=false.
additional_chat_templates does not exist on "main"
```

### Expected behavior

It creates the model objects like it did before.

Comments:
Hi @harveyz0, can you try installing from `main` with `pip install --upgrade git+https://github.com/huggingface/transformers.git` and tell us if you're still getting the issue?

Sure hold please

I don't know how to do pip and venv. I install all my libraries to the system. Which is clearly how I've gotten into this mess.
```
$ sudo pip install --break-system-packages --upgrade git+https://github.com/huggingface/transformers.git
Collecting git+https://github.com/huggingface/transformers.git
  Cloning https://github.com/huggingface/transformers.git to /tmp/pip-req-build-1k24fp51
  Running command git clone --filter=blob:none --quiet https://github.com/huggingface/transformers.git /tmp/pip-req-build-1k24fp51
  Resolved https://github.com/huggingface/transformers.git to commit b433ec8b505118a6c89ac92bdb82a643860e94f7
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: filelock in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (3.20.0)
Collecting huggingface-hub==1.0.0.rc6 (from transformers==5.0.0.dev0)
  Downloading huggingface_hub-1.0.0rc6-py3-none-any.whl.metadata (14 kB)
Requirement already satisfied: numpy>=1.17 in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (2.3.4)
Requirement already satisfied: packaging>=20.0 in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (25.0)
Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (6.0.3)
Requirement already satisfied: regex!=2019.12.17 in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (2025.9.18)
Requirement already satisfied: requests in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (2.32.5)
Collecting tokenizers<=0.23.0,>=0.22.0 (from transformers==5.0.0.dev0)
  Downloading tokenizers-0.22.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.8 kB)
Collecting typer-slim (from transformers==5.0.0.dev0)
  Downloading typer_slim-0.20.0-py3-none-any.whl.metadata (16 kB)
Collecting safetensors>=0.4.3 (from transformers==5.0.0.dev0)
  Downloading safetensors-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.1 kB)
Requirement already satisfied: tqdm>=4.27 in /usr/lib/python3.13/site-packages (from transformers==5.0.0.dev0) (4.67.1)
Requirement already satisfied: fsspec>=2023.5.0 in /usr/lib/python3.13/site-packages (from huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (2025.9.0)
Requirement already satisfied: httpx<1,>=0.23.0 in /usr/lib/python3.13/site-packages (from huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (0.28.1)
Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/lib/python3.13/site-packages (from huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (4.15.0)
Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/lib/python3.13/site-packages (from huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (1.2.0)
Requirement already satisfied: anyio in /usr/lib/python3.13/site-packages (from httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (4.11.0)
Requirement already satisfied: certifi in /usr/lib/python3.13/site-packages (from httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (2025.10.5)
Requirement already satisfied: httpcore==1.* in /usr/lib/python3.13/site-packages (from httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (1.0.9)
Requirement already satisfied: idna in /usr/lib/python3.13/site-packages (from httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (3.11)
Requirement already satisfied: h11>=0.16 in /usr/lib/python3.13/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (0.16.0)
Requirement already satisfied: sniffio>=1.1 in /usr/lib/python3.13/site-packages (from anyio->httpx<1,>=0.23.0->huggingface-hub==1.0.0.rc6->transformers==5.0.0.dev0) (1.3.1)
Requirement already satisfied: charset_normalizer<4,>=2 in /usr/lib/python3.13/site-packages (from requests->transformers==5.0.0.dev0) (3.4.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3.13/site-packages (from requests->transformers==5.0.0.dev0) (2.5.0)
Requirement already satisfied: click>=8.0.0 in /usr/lib/python3.13/site-packages (from typer-slim->transformers==5.0.0.dev0) (8.2.1)
Downloading huggingface_hub-1.0.0rc6-py3-none-any.whl (502 kB)
Downloading tokenizers-0.22.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 8.3 MB/s  0:00:00
Downloading safetensors-0.6.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (485 kB)
Downloading typer_slim-0.20.0-py3-none-any.whl (47 kB)
Building wheels for collected packages: transformers
  Building wheel for transformers (pyproject.toml) ... done
  Created wheel for transformers: filename=transformers-5.0.0.dev0-py3-none-any.whl size=11349957 sha256=e78c283d8a30a78fc722586ac7ebddb3725f600ebe38600c0e5a7c90cee297e0
  Stored in directory: /tmp/pip-ephem-wheel-cache-0jhv5g69/wheels/90/86/bb/8ad35b428289429952d8316d30f64abedae0ab2fcee0f4f46f
Successfully built transformers
Installing collected packages: typer-slim, safetensors, huggingface-hub, tokenizers, transformers
  Attempting uninstall: huggingface-hub
    Found existing installation: huggingface_hub 1.0.1
    Uninstalling huggingface_hub-1.0.1:
      Successfully uninstalled huggingface_hub-1.0.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
datasets 4.3.0 requires multiprocess<0.70.17, but you have multiprocess 0.70.18 which is incompatible.
Successfully installed huggingface-hub-1.0.0rc6 safetensors-0.6.2 tokenizers-0.22.1 transformers-5.0.0.dev0 typer-slim-0.20.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
```

```
$ transformers env                                                                                                                                                                                          ──(Mon,Nov03)─┘
Traceback (most recent call last):
  File "/usr/bin/transformers", line 3, in <module>
    from transformers.cli.transformers import main
  File "/usr/lib/python3.13/site-packages/transformers/cli/transformers.py", line 23, in <module>
    from transformers.cli.serve import Serve
  File "/usr/lib/python3.13/site-packages/transformers/cli/serve.py", line 37, in <module>
    from openai.types.chat.chat_completion import Choice
ModuleNotFoundError: No module named 'openai'
zsh: exit 1     transformers env
```

Don't know why that happened but fixed it with `pacman -S extras/python-openai`

Once that is installed I can do this.
```
$ transformers env
Copy-and-paste the text below in your GitHub issue and FILL OUT the two last points.

- `transformers` version: 5.0.0.dev0
- Platform: Linux-6.12.56-1-lts-x86_64-with-glibc2.42
- Python version: 3.13.7
- Huggingface_hub version: 1.0.0.rc6
- Safetensors version: 0.6.2
- Accelerate version: not installed
- Accelerate config: not found
- DeepSpeed version: not installed
- PyTorch version (accelerator?): 2.9.0 (CUDA)
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA RTX 6000 Ada Generation
```

But it looks all it really did was downgrade my huggingface hub library down to 1.0


It's okay, we've all had the pain of having to learn `venv` or `conda` lol. I think the issue here is just that you're installing to the system Python, which needs root permissions and causes a lot of problems - you might find it simpler if you used [uv](https://github.com/astral-sh/uv) to get some user-local python environments and followed the instructions in their README to install packages.

I'm not totally sure if this is an environment issue on your end or an actual Transformers issue as a result, but if you clean up your local env and you still think there's a problem, or if anyone else is encountering this, let us know! 

Hi, I'm not sure what I experienced has any relevance or relation to the issue discussed here but for me it seems close enough to consider it's worth sharing. So here we go:

I'm on windows 11, my main use of the entire Python installation is running ComfyUI. I also don't understand virtual environment so everything in Python is installed system wide. I use Python 3.13.9 downloaded from here https://github.com/astral-sh/python-build-standalone.git and simply unzipped into a folder and then I set the appropriate path variables in the windows environment settings.

The situation with transformers on my system is this : the current stable release 4.57.1 is requiring huggingface_hub 0.36.0, which is fine, if you install transformers with pip it will also download huggingface_hub 0.36.0. But the current stable huggingface_hub version is 1.0 or even 1.0.1. If you run `pip list -o' and make the mistake to update hugghuggingface_hub to latest stable version, then ComfyUI will not start any more. This can be solved by force reinstalling transformers with pip again which will uninstall huggingface_hub 1.0 and install 0.36.0.

On the other hand if you compile transformers from latest git the resulted transformers 5.0 dev wheel installs also as a requirement huggingface_hub, but not final 1.0.1, but instead a release candidate 6 for 1.0. Fine, ComfyUI works with this combination too. With the exception of some projects that are not up to date with the changes in hugginface_hub 1.0. (See for example an issue I opened yesterday at this project before I could figure out this incompatibilities: https://github.com/kijai/ComfyUI-MMAudio/issues/53 )

Of course, installing with pip the official stable transformers 4.57.1 + huggingface_hub 0.36.0 makes everything work normally for now, but probably the transition to huggingface_hub 1.0 makes things a little chaotic for now for some more inexperienced users like myself.


Hi @jovan2009, yes, this can be confusing. In general, `transformers` expects specific versions of other libraries like `huggingface_hub` or `tokenizers`. You generally shouldn't update those separately. Instead, just install `transformers` and the other dependencies will be resolved for you.

This situation is similar for other libraries with tight interdependencies, like `torch` and `torchvision`/`torchaudio`.

@harveyz0 since you are on arch, check if you have an older version of huggingface-hub in your cache 

```
$ ls -lh /var/cache/pacman/pkg/python-huggingface-hub-*
```

Install an older version (for me that was 0.36)
```
# pacman -U /var/cache/pacman/pkg/python-huggingface-hub-1:0.36.0-1-any.pkg.tar.zst
```

As mentioned these packages appear to have tight interdependencies, and the current python-transformers release is not compatible with the latest huggingface-hub release. 

You may also want to ignore package updates and set a note to yourself to remove the ignorepkg once transformers has had a compatible release

```
# nano /etc/pacman.conf
```
Add:
```
IgnorePkg = huggingface-hub
```

Even in version 4.57.1, the problem still persist and it's related to [this line](https://github.com/huggingface/transformers/blob/v4.57.1/setup.py#L118).

> Even in version 4.57.1, the problem still persist and it's related to [this line](https://github.com/huggingface/transformers/blob/v4.57.1/setup.py#L118).

That line I think is good to be there. Current stable huggingface_hub 1.xx  breaks projects that otherwise work well with current transformers 4.57.1, as I mentioned in my previous comment in this thread.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.