Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import Tool if old version of huggingface_hub is installed #23303

Closed
4 tasks
freddyaboulton opened this issue May 11, 2023 · 6 comments
Closed
4 tasks

Comments

@freddyaboulton
Copy link
Contributor

System Info

  • transformers version: 4.29.0
  • Platform: macOS-12.2.1-arm64-arm-64bit
  • Python version: 3.9.16
  • Huggingface_hub version: 0.13.4
  • Safetensors version: not installed
  • PyTorch version (GPU?): not installed (NA)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@sgugger @LysandreJik

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

  1. Have huggingface_hub 0.13.4 installed
  2. Import Tool class
 from transformers import Tool
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~/miniconda3/envs/gradio-tools/lib/python3.9/site-packages/transformers/utils/import_utils.py:1172, in _LazyModule._get_module(self, module_name)
   1171 try:
-> 1172     return importlib.import_module("." + module_name, self.__name__)
   1173 except Exception as e:

File ~/miniconda3/envs/gradio-tools/lib/python3.9/importlib/__init__.py:127, in import_module(name, package)
    126         level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1030, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1007, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:986, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:680, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:850, in exec_module(self, module)

File <frozen importlib._bootstrap>:228, in _call_with_frames_removed(f, *args, **kwds)

File ~/miniconda3/envs/gradio-tools/lib/python3.9/site-packages/transformers/tools/base.py:27
     26 from huggingface_hub import CommitOperationAdd, HfFolder, create_commit, create_repo, hf_hub_download, metadata_update
---> 27 from huggingface_hub.utils import RepositoryNotFoundError, get_session
     29 from ..dynamic_module_utils import custom_object_save, get_class_from_dynamic_module, get_imports

ImportError: cannot import name 'get_session' from 'huggingface_hub.utils' (/Users/freddy/miniconda3/envs/gradio-tools/lib/python3.9/site-packages/huggingface_hub/utils/__init__.py)

Expected behavior

Importing tool class does not raise an error.

Upgrading to hugginggface_hub version 0.14.1 fixes the issue!

@amyeroberts
Copy link
Collaborator

Thanks for reporting! This will be addressed in #23301

@github-actions
Copy link

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 are likely to be ignored.

@Daa06
Copy link

Daa06 commented Feb 29, 2024

Hi I have the exact same error

from transformers import pipeline
...:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3437, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
from transformers import pipeline
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/transformers/init.py", line 26, in
from . import dependency_versions_check
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/transformers/dependency_versions_check.py", line 16, in
from .utils.versions import require_version, require_version_core
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/transformers/utils/init.py", line 18, in
from huggingface_hub import get_full_repo_name # for backward compatibility
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/huggingface_hub/init.py", line 370, in getattr
submod = importlib.import_module(submod_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 51, in
from ._commit_api import (
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/huggingface_hub/_commit_api.py", line 17, in
from huggingface_hub import get_session
ImportError: cannot import name 'get_session' from 'huggingface_hub' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/huggingface_hub/init.py)

my hugginggface_hub version is Version: 0.21.3
and transformers 4.38.1

@amyeroberts
Copy link
Collaborator

amyeroberts commented Mar 1, 2024

Hi @Daa06, that's very odd - I'm not able to replicate this error with this hub or transformers version.

Can you verify your versions running in your python session:

>>> import huggingface_hub
>>> import transformers
>>> print(huggingface_hub.__version__)
>>> print(transformers.__version__)

@Daa06
Copy link

Daa06 commented Mar 3, 2024

Hi @Daa06, that's very odd - I'm not able to replicate this error with this hub or transformers version.

Can you verify your versions running in your python session:

>>> import huggingface_hub
>>> import transformers
>>> print(huggingface_hub.__version__)
>>> print(transformers.__version__)

Okay i tried in fact the line "import transformers" give me the same error as above. But I check and it is installed
However the print(huggingface_hub.version) give me 0.20.3

@amyeroberts
Copy link
Collaborator

@Daa06 I'd suggest trying to reinstall transformers in your environment: pip install -U transformers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants