huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
1.82k stars 470 forks source link

CommitOperationAdd cant be imported from huggingface_hub #2352

Open connorchenn opened 1 week ago

connorchenn commented 1 week ago

I am getting the following error: from huggingface_hub import CommitOperationAdd, SpaceHardware, SpaceStage ImportError: cannot import name 'CommitOperationAdd' from 'huggingface_hub' (/Users/connor/opt/anaconda3/envs/LMSYS/lib/python3.12/site-packages/huggingface_hub/init.py). Did you mean: 'CommitOperation'?

I've seen similar errors on other threads, but none of the solutions proposed seem to work. huggingface_hub is currently installed in my conda environment. I have tried uninstalling and installing hugginface_hub, but this doesn't seem to be working. My current huggingface_hub version is 0.23.4. Any help will be greatly appreciated, thank you.

Wauplin commented 1 week ago

Hi @connorchenn, I'm sorry you are facing this issue. Could you try to install huggingface_hub from source. We pushed a fix that should help you get a better error message (see https://github.com/huggingface/huggingface_hub/pull/2342). The fix will be shipped in next release (coming soon!) and should help a lot users facing this import error issue. Please let me know if that's the case for you.

sundaqiang commented 6 days ago

Hi @connorchenn, I'm sorry you are facing this issue. Could you try to install huggingface_hub from source. We pushed a fix that should help you get a better error message (see #2342). The fix will be shipped in next release (coming soon!) and should help a lot users facing this import error issue. Please let me know if that's the case for you.

After installing huggingface hub from source code, the problem persists.

image image

Wauplin commented 5 days ago

@sundaqiang could you provide your pip freeze list + the python code that generates the problem? Also, could you retry in a simple Python interpreter to run from huggingface_hub import CommitOperationAdd?

sundaqiang commented 5 days ago

pip freeze is normal. The file that causes the problem is code in the gradio_client library

image

Wauplin commented 5 days ago

What I meant is if you could share which packages are installed. It is a setup problem, not an issue with huggingface_hub or gradio_client themselves. With a clean install it should be possible to import it like this: image

sundaqiang commented 5 days ago

aiofiles==23.2.1 altair==5.3.0 annotated-types==0.7.0 antlr4-python3-runtime==4.9.3 anyio==4.4.0 asttokens==2.4.1 attrs==23.2.0 av==12.1.0 Brotli @ file:///C:/b/abs_3d36mno480/croot/brotli-split_1714483178642/work certifi==2024.6.2 cffi==1.16.0 charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work click==8.1.7 cn2an==0.5.22 colorama==0.4.6 contourpy==1.2.1 cycler==0.12.1 decorator==5.1.1 distro==1.9.0 dnspython==2.6.1 einops==0.8.0 einx==0.3.0 email_validator==2.2.0 encodec==0.1.1 executing==2.0.1 fastapi==0.111.0 fastapi-cli==0.0.4 ffmpy==0.3.2 filelock @ file:///C:/b/abs_f2gie28u58/croot/filelock_1700591233643/work fonttools==4.53.0 frozendict==2.4.4 fsspec==2024.6.1 gmpy2 @ file:///C:/ci_311/gmpy2_1677743390134/work gradio==4.37.1 gradio_client==1.0.2 h11==0.14.0 httpcore==1.0.5 httptools==0.6.1 httpx==0.27.0 huggingface-hub==0.23.4 idna==3.7 importlib_resources==6.4.0 intel-openmp==2021.4.0 ipython==8.26.0 jedi==0.19.1 jieba==0.42.1 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 kiwisolver==1.4.5 llvmlite==0.43.0 markdown-it-py==3.0.0 MarkupSafe==2.1.5 matplotlib==3.9.0 matplotlib-inline==0.1.7 mdurl==0.1.2 mkl==2021.4.0 mkl-fft==1.3.1 mkl-random @ file:///C:/ci_311/mkl_random_1676481991689/work mkl-service==2.4.0 mpmath==1.3.0 networkx @ file:///C:/b/abs_3bxnu56g9d/croot/networkx_1717597507456/work numba==0.60.0 numpy==1.26.4 omegaconf==2.3.0 openai==1.35.7 orjson==3.10.5 packaging==24.1 pandas==2.2.2 parso==0.8.4 pillow==10.3.0 proces==0.1.7 prompt_toolkit==3.0.47 pure-eval==0.2.2 pybase16384==0.3.7 pycparser==2.22 pydantic==2.7.4 pydantic_core==2.18.4 pydub==0.25.1 Pygments==2.18.0 pyparsing==3.1.2 pypinyin==0.51.0 PySocks @ file:///C:/ci_311/pysocks_1676425991111/work python-dateutil==2.9.0.post0 python-dotenv==1.0.1 python-multipart==0.0.9 pytz==2024.1 PyYAML==6.0.1 referencing==0.35.1 regex==2024.5.15 requests @ file:///C:/b/abs_9c5n24p1y7/croot/requests_1716902867639/work rich==13.7.1 rpds-py==0.18.1 ruff==0.5.0 safetensors==0.4.3 scipy==1.14.0 semantic-version==2.10.0 shellingham==1.5.4 six==1.16.0 sniffio==1.3.1 socksio==1.0.0 stack-data==0.6.3 starlette==0.37.2 sympy==1.12.1 tbb==2021.13.0 tokenizers==0.19.1 tomlkit==0.12.0 toolz==0.12.1 torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1 tqdm==4.66.4 traitlets==5.14.3 transformers==4.42.2 typer==0.12.3 typing_extensions @ file:///C:/b/abs_0as9mdbkfl/croot/typing_extensions_1715268906610/work tzdata==2024.1 ujson==5.10.0 urllib3==2.2.2 uvicorn==0.30.1 vector-quantize-pytorch==1.14.42 vocos==0.1.0 watchfiles==0.22.0 wcwidth==0.2.13 websockets==11.0.3 win-inet-pton @ file:///C:/ci_311/win_inet_pton_1676425458225/work

(ChatTTS) E:\Python\ChatTTS_colab>pip freeze
aiofiles==23.2.1 altair==5.3.0 annotated-types==0.7.0 antlr4-python3-runtime==4.9.3 anyio==4.4.0 asttokens==2.4.1 attrs==23.2.0 av==12.1.0 Brotli @ file:///C:/b/abs_3d36mno480/croot/brotli-split_1714483178642/work certifi==2024.6.2 cffi==1.16.0 charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work click==8.1.7 cn2an==0.5.22 colorama==0.4.6 contourpy==1.2.1 cycler==0.12.1 decorator==5.1.1 distro==1.9.0 dnspython==2.6.1 einops==0.8.0 einx==0.3.0 email_validator==2.2.0 encodec==0.1.1 executing==2.0.1 fastapi==0.111.0 fastapi-cli==0.0.4 ffmpy==0.3.2 filelock @ file:///C:/b/abs_f2gie28u58/croot/filelock_1700591233643/work fonttools==4.53.0 frozendict==2.4.4 fsspec==2024.6.1 gmpy2 @ file:///C:/ci_311/gmpy2_1677743390134/work gradio==4.37.1 gradio_client==1.0.2 h11==0.14.0 httpcore==1.0.5 httptools==0.6.1 httpx==0.27.0 huggingface-hub==0.23.4 idna==3.7 importlib_resources==6.4.0 intel-openmp==2021.4.0 ipython==8.26.0 jedi==0.19.1 jieba==0.42.1 Jinja2==3.1.4 jsonschema==4.22.0 jsonschema-specifications==2023.12.1 kiwisolver==1.4.5 llvmlite==0.43.0 markdown-it-py==3.0.0 MarkupSafe==2.1.5 matplotlib==3.9.0 matplotlib-inline==0.1.7 mdurl==0.1.2 mkl==2021.4.0 mkl-fft==1.3.1 mkl-random @ file:///C:/ci_311/mkl_random_1676481991689/work mkl-service==2.4.0 mpmath==1.3.0 networkx @ file:///C:/b/abs_3bxnu56g9d/croot/networkx_1717597507456/work numba==0.60.0 numpy==1.26.4 omegaconf==2.3.0 openai==1.35.7 orjson==3.10.5 packaging==24.1 pandas==2.2.2 parso==0.8.4 pillow==10.3.0 proces==0.1.7 prompt_toolkit==3.0.47 pure-eval==0.2.2 pybase16384==0.3.7 pycparser==2.22 pydantic==2.7.4 pydantic_core==2.18.4 pydub==0.25.1 Pygments==2.18.0 pyparsing==3.1.2 pypinyin==0.51.0 PySocks @ file:///C:/ci_311/pysocks_1676425991111/work python-dateutil==2.9.0.post0 python-dotenv==1.0.1 python-multipart==0.0.9 pytz==2024.1 PyYAML==6.0.1 referencing==0.35.1 regex==2024.5.15 requests @ file:///C:/b/abs_9c5n24p1y7/croot/requests_1716902867639/work rich==13.7.1 rpds-py==0.18.1 ruff==0.5.0 safetensors==0.4.3 scipy==1.14.0 semantic-version==2.10.0 shellingham==1.5.4 six==1.16.0 sniffio==1.3.1 socksio==1.0.0 stack-data==0.6.3 starlette==0.37.2 sympy==1.12.1 tbb==2021.13.0 tokenizers==0.19.1 tomlkit==0.12.0 toolz==0.12.1 torch==2.3.1 torchaudio==2.3.1 torchvision==0.18.1 tqdm==4.66.4 traitlets==5.14.3 transformers==4.42.2 typer==0.12.3 typing_extensions @ file:///C:/b/abs_0as9mdbkfl/croot/typing_extensions_1715268906610/work tzdata==2024.1 ujson==5.10.0 urllib3==2.2.2 uvicorn==0.30.1 vector-quantize-pytorch==1.14.42 vocos==0.1.0 watchfiles==0.22.0 wcwidth==0.2.13 websockets==11.0.3 win-inet-pton @ file:///C:/ci_311/win_inet_pton_1676425458225/work