Search code examples
python-3.xmacospipconda

ImportError: cannot import name 'hf_hub_download' from 'huggingface_hub'


Problem

I need a conda environment for DeepLabCut, I setted it up and I open python console, but I cannot import from huggingface_hub import hf_hub_download.

Scenario

Here below there is an example of my console output

(base) user@macbook ~ % conda activate TEST_ENV                                                 
(TEST_ENV) user@macbook ~ % python
Python 3.9.18 (main, Sep 11 2023, 08:38:23) 
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import huggingface_hub
>>> from huggingface_hub import hf_hub_download
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'hf_hub_download' from 'huggingface_hub' (/usr/local/anaconda3/envs/TEST_ENV/lib/python3.9/site-packages/huggingface_hub/__init__.py)
>>> 

The strange fact is that I can import the parent module with huggingface_hub, so this error comes out only when I try to import its child module called hf_hub_download

Also tried

to reinstall anaconda, launch conda clean --all, change environment

Thanks so much for the attention payed.


Solution

  • need to install chardet conda install chardet