I am encountering an ImportError
when running a Python script that imports CommitInfo
from the huggingface_hub package. The error message is as follows:
ImportError: cannot import name 'CommitInfo' from 'huggingface_hub' (/home/user/anaconda3/envs/kg/lib/python3.9/site-packages/huggingface_hub/__init__.py)
I have ensured that the huggingface_hub
package is installed and up-to-date. Here is the full traceback of the error:
Traceback (most recent call last):
...
import datasets
File "/home/user/anaconda3/envs/kg/lib/python3.9/site-packages/datasets/__init__.py", line 17, in <module>
from .arrow_dataset import Dataset
File "/home/user/anaconda3/envs/kg/lib/python3.9/site-packages/datasets/arrow_dataset.py", line 63, in <module>
from huggingface_hub import (
ImportError: cannot import name 'CommitInfo' from 'huggingface_hub' (/home/user/anaconda3/envs/kg/lib/python3.9/site-packages/huggingface_hub/__init__.py)
I work on Ubuntu 24.04
I have tried the following steps to resolve the issue:
- Checked the version of
huggingface_hub
:
python -c "import huggingface_hub; print(huggingface_hub.__version__)"
- Upgraded
huggingface_hub
to the latest version:
pip install --upgrade huggingface_hub
- Cleanly reinstalled
huggingface_hub
:
pip uninstall huggingface_hub
pip install huggingface_hub
- Checked the
import
path to ensure there are no conflicts:
python -c "import huggingface_hub; print(huggingface_hub.__file__)"
I expected these steps to resolve the ImportError
, but the issue persists. Any guidance on resolving this import error would be greatly appreciated.