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

Import Error : cannot import name 'create_repo' from 'huggingface_hub' #15062

Closed
santanumitra22 opened this issue Jan 7, 2022 · 35 comments
Closed

Comments

@santanumitra22
Copy link

santanumitra22 commented Jan 7, 2022

Working with BERT Text Classification,i found this error

import torch
from tqdm.notebook import tqdm

from transformers import BertTokenizer

from torch.utils.data import TensorDataset

from transformers import BertForSequenceClassification

ImportError: cannot import name 'create_repo' from 'huggingface_hub' (C:\ProgramData\Anaconda3\lib\site-packages\huggingface_hub_init_.py)

How to solve this?

@frankhart2018
Copy link

@santanumitra22 Which transformers version are you using?

@santanumitra22
Copy link
Author

Version: 4.15.0 @frankhart2018

@frankhart2018
Copy link

And is you huggingface_hub version 0.2.1?

@santanumitra22
Copy link
Author

no,
huggingface_hub 0.0.8

@frankhart2018
Copy link

That's probably the issue, can you try upgrading to 0.2.1, its working fine for me when I am using 0.2.1

@Yansera
Copy link

Yansera commented Jan 10, 2022

Same issue here, my transformers version is 4.15.0., and the huggingface_hub version is 0.2.1. However, it does not work.

@rsm5909
Copy link

rsm5909 commented Jan 10, 2022

Same issue here, my transformers version is 4.15.0., and the huggingface_hub version is 0.2.1. However, it does not work.

I was able to correct this by restarting the python kernel (working in Jupyter Lab) after logging in to the CLI

@Yansera
Copy link

Yansera commented Jan 12, 2022

Error fixed, thanks! :)

@rsmith49
Copy link

This happened for me from a fresh install of

conda install transformers

on an Ubuntu Deep Learning AMI. Is there a huggingface_hub dependency that should be updated?

@DevavratSinghBisht
Copy link

That's probably the issue, can you try upgrading to 0.2.1, its working fine for me when I am using 0.2.1

Faced same issue, updating to 0.2.1 helped, thanks!

@github-actions
Copy link

github-actions bot commented Feb 6, 2022

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.

@GeorgiosEtsias
Copy link

In my case downgrading python 3.8 to 3.7 is what solved the problem.

@github-actions
Copy link

github-actions bot commented Mar 8, 2022

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.

@iknoorjobs
Copy link

Same issue here, my transformers version is 4.15.0., and the huggingface_hub version is 0.2.1 both updated to latest version. However, it does not work. I'm still getting the following import error

Import Error : cannot import name 'create_repo' from 'huggingface_hub'

@LysandreJik
Copy link
Member

The latest huggingface_hub version is v0.5.1; how did you identify that v0.2.1 was the latest? This is definitely an error with the wrong version being installed.

@iknoorjobs
Copy link

Hi @LysandreJik, thanks! Yes, I tried conda update huggingface_hub and conda update transformers but it doesn't work. I finally solved this by doing a fresh installation of both of these in a new environment.

@LysandreJik
Copy link
Member

Glad you got it to work! Very weird that conda refused to update your packages, let me know if it happens again!

@stefanhgm
Copy link

stefanhgm commented May 10, 2022

I experienced the same problem today:

> conda create -n test_env python=3.7
> conda activate test_env
> conda install huggingface_hub
> conda list | grep hugging
huggingface_hub           0.2.1              pyhd3eb1b0_0

Could maybe the python version be the problem? When using conda-forge I get the most recent version:

> conda create -n test_env python=3.7
> conda activate test_env
> conda install -c conda-forge huggingface_hub
> conda list | grep hugging
huggingface_hub           0.5.1              pyhd8ed1ab_0    conda-forge

Also, installing subsequent dependencies not from conda-forge actually downgraded huggingface_hub to 0.1.7, so people that run into the same problem might try to install their remaining packages from conda-forge as well an keep an eye on conda whether it attempts to downgrade huggingface_hub.

@roysubhankar
Copy link

For me conda update huggingface_hub and conda update transformers worked nicely.

@cgr71ii
Copy link

cgr71ii commented Sep 16, 2022

Here's my two cents: I had installed transformers 4.10.3 and huggingface-hub 0.4.0 and was throwing

ImportError: cannot import name 'RepositoryNotFoundError' from 'huggingface_hub.utils'

Then I ran

pip install --upgrade huggingface-hub

After that, huggingface-hub was updated to version 0.9.1, didn't modify any other version of my environment, and solved the problem.

@brando90
Copy link

brando90 commented Oct 3, 2022

in case this doesn't work for you upgrade pip e.g.

/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python -m pip install --upgrade pip
pip install --upgrade huggingface-hub

@brando90
Copy link

brando90 commented Oct 3, 2022

huggingface-hub                                   0.10.0
transformers                                      4.13.0

my issue happens and above is true

@brando90
Copy link

brando90 commented Oct 3, 2022

what about upgrading all 3?

/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python -m pip install --upgrade pip
pip install --upgrade transformers
pip install --upgrade huggingface-hub
pip install --upgrade datasets

ok failed but now the error is:

Traceback (most recent call last):
  File "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 11, in <module>
  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 "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/__init__.py", line 30, in <module>
    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 "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/dependency_versions_check.py", line 36, in <module>
    from .utils import is_tokenizers_available
ImportError: cannot import name 'is_tokenizers_available' from 'transformers.utils' (/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/utils/__init__.py)

@brando90
Copy link

brando90 commented Oct 3, 2022

/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python -m pip install --upgrade pip
pip install --upgrade tokenizers

upgraded correctly trom 0.12.1 to 0.13.0 still fails.

(meta_learning) ❯ pip list 
Package                                           Version    Editable project location
------------------------------------------------- ---------- ------------------------------------------------------------------------------
absl-py                                           1.0.0
aiohttp                                           3.8.1
aiosignal                                         1.2.0
antlr4-python3-runtime                            4.8
argcomplete                                       2.0.0
async-timeout                                     4.0.1
attrs                                             21.4.0
automl-meta-learning                              0.1.0      /Users/brandomiranda/automl-meta-learning/automl-proj-src
bcj-cffi                                          0.5.1
boto                                              2.49.0
Bottleneck                                        1.3.4
Brotli                                            1.0.9
brotlicffi                                        1.0.9.2
brotlipy                                          0.7.0
cachetools                                        4.2.4
certifi                                           2022.9.14
cffi                                              1.15.1
charset-normalizer                                2.0.9
cherry-rl                                         0.1.4
click                                             8.0.3
cloudpickle                                       2.0.0
colorama                                          0.4.4
configparser                                      5.2.0
conllu                                            4.4.1
crcmod                                            1.7
cryptography                                      37.0.1
cycler                                            0.11.0
Cython                                            0.29.25
dataclasses                                       0.6
datasets                                          2.5.1
dill                                              0.3.4
diversity-for-predictive-success-of-meta-learning 0.0.1      /Users/brandomiranda/diversity-for-predictive-success-of-meta-learning/div_src
docker-pycreds                                    0.4.0
editdistance                                      0.6.0
et-xmlfile                                        1.1.0
fairseq                                           0.10.0
fastcluster                                       1.2.4
fasteners                                         0.17.3
filelock                                          3.6.0
fonttools                                         4.28.3
frozenlist                                        1.2.0
fsspec                                            2022.7.1
gcs-oauth2-boto-plugin                            3.0
gitdb                                             4.0.9
GitPython                                         3.1.24
google-apitools                                   0.5.32
google-auth                                       2.3.3
google-auth-oauthlib                              0.4.6
google-reauth                                     0.1.1
grpcio                                            1.42.0
gsutil                                            5.6
gym                                               0.21.0
h5py                                              3.6.0
higher                                            0.2.1
httplib2                                          0.20.4
huggingface-hub                                   0.10.0
hydra-core                                        1.1.1
idna                                              3.3
importlib-metadata                                4.11.3
joblib                                            1.1.0
kiwisolver                                        1.3.2
lark-parser                                       0.12.0
learn2learn                                       0.1.7
lxml                                              4.8.0
Markdown                                          3.3.6
matplotlib                                        3.5.1
mkl-fft                                           1.3.1
mkl-random                                        1.2.2
mkl-service                                       2.4.0
monotonic                                         1.6
multidict                                         5.2.0
multiprocess                                      0.70.12.2
multivolumefile                                   0.2.3
munkres                                           1.1.4
networkx                                          2.6.3
numexpr                                           2.8.1
numpy                                             1.21.5
oauth2client                                      4.1.3
oauthlib                                          3.1.1
omegaconf                                         2.1.1
openpyxl                                          3.0.10
ordered-set                                       4.0.2
packaging                                         21.3
pandas                                            1.4.2
pathtools                                         0.1.2
Pillow                                            9.0.1
pip                                               22.2.2
plotly                                            5.4.0
portalocker                                       2.3.2
progressbar2                                      3.55.0
promise                                           2.3
protobuf                                          3.19.1
psutil                                            5.8.0
py7zr                                             0.16.1
pyarrow                                           9.0.0
pyasn1                                            0.4.8
pyasn1-modules                                    0.2.8
pycparser                                         2.21
pycryptodomex                                     3.15.0
pyOpenSSL                                         22.0.0
pyparsing                                         3.0.6
pyppmd                                            0.16.1
PySocks                                           1.7.1
python-dateutil                                   2.8.2
python-utils                                      2.5.6
pytz                                              2021.3
pyu2f                                             0.1.5
PyYAML                                            6.0
pyzstd                                            0.14.4
qpth                                              0.0.15
regex                                             2021.11.10
requests                                          2.28.1
requests-oauthlib                                 1.3.0
responses                                         0.18.0
retry-decorator                                   1.1.1
rsa                                               4.7.2
sacrebleu                                         2.0.0
sacremoses                                        0.0.46
scikit-learn                                      1.0.1
scipy                                             1.7.3
seaborn                                           0.11.2
sentry-sdk                                        1.5.1
setproctitle                                      1.2.2
setuptools                                        58.0.4
shortuuid                                         1.0.8
six                                               1.16.0
sklearn                                           0.0
smmap                                             5.0.0
subprocess32                                      3.5.4
tabulate                                          0.8.9
tenacity                                          8.0.1
tensorboard                                       2.7.0
tensorboard-data-server                           0.6.1
tensorboard-plugin-wit                            1.8.0
termcolor                                         1.1.0
texttable                                         1.6.4
threadpoolctl                                     3.0.0
tokenizers                                        0.12.1
torch                                             1.9.1
torchaudio                                        0.9.1
torchmeta                                         1.8.0
torchtext                                         0.10.1
torchvision                                       0.10.1
tornado                                           6.1
tqdm                                              4.62.3
transformers                                      4.22.2
typing_extensions                                 4.3.0
ultimate-anatome                                  0.1.1      /Users/brandomiranda/ultimate-anatome
ultimate-aws-cv-task2vec                          0.0.1      /Users/brandomiranda/ultimate-aws-cv-task2vec
ultimate-utils                                    0.6.1      /Users/brandomiranda/ultimate-utils/ultimate-utils-proj-src
urllib3                                           1.26.11
wandb                                             0.13.3
Werkzeug                                          2.0.2
wheel                                             0.37.0
xxhash                                            2.0.2
yarl                                              1.8.1
yaspin                                            2.1.0
zipp                                              3.8.0

@brando90
Copy link

brando90 commented Oct 3, 2022

did:

pip install pytorch-transformers

didn't work same eroor about tokenizer.

@brando90
Copy link

brando90 commented Oct 3, 2022

trying:

/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin/python -m pip install --upgrade pip
pip install --upgrade torch
pip install --upgrade torchvision
pip install --upgrade torchtext
pip install --upgrade torchaudio

# pip install --upgrade torchmeta
pip uninstall torchmeta

still fails with:

Traceback (most recent call last):
  File "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 11, in <module>
  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 "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/__init__.py", line 30, in <module>
    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 "/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/dependency_versions_check.py", line 36, in <module>
    from .utils import is_tokenizers_available
ImportError: cannot import name 'is_tokenizers_available' from 'transformers.utils' (/Users/brandomiranda/opt/anaconda3/envs/meta_learning/lib/python3.9/site-packages/transformers/utils/__init__.py)

SO post: https://stackoverflow.com/questions/73939929/how-to-resolve-the-hugging-face-error-importerror-cannot-import-name-is-tokeni

@conan1024hao
Copy link
Contributor

I was able to correct this by restarting the python kernel (working in Jupyter Lab) after logging in to the CLI

solved by @rsm5909 's, thanks!

@damlitos
Copy link

restarting Jupyter notebook has solved the problem

@XitraQ
Copy link

XitraQ commented Aug 29, 2023

omg, this tooooook too long
none of the above worked, not sure if i tried it all, but i tried

This is what worked for me:
open cmd in
venv/scripts
write:

pip uninstall tqdm
pip install tqdm

or get it upgraded, since this one was old for me!
alternative commands

py -m pip uninstall tqdm
py -m pip install tqdm

OR python -m

The issue is that one of your tqdm's are not same version
you have to go to huggingface_hub/utils probably too and do the same

and maybe even go into init.py and edit with VSCode or something the top code
# from . import tqdm as _tqdm # _tqdm is the module
just add the # or remove the whole line

I might have missed something, because I tried so much
Hope it helps anyone else

@BitCalSaul
Copy link

My previous issue is "cannot import name 'get_full_repo_name' from 'huggingface_hub'", and I use the command "conda install chardet" to fix it.

normalllll added a commit to normalllll/ultimatevocalremovergui that referenced this issue Apr 2, 2024
```
from huggingface_hub import get_full_repo_name  # for backward compatibility
ImportError: cannot import name 'get_full_repo_name' from 'huggingface_hub' 
```
huggingface/transformers#15062
@hughesadam87
Copy link

I'm getting this issue now - april 2024. Clean virtual env pip install transformers and huggingface_Hub

@lixikun
Copy link

lixikun commented Jun 27, 2024

conda install chardet

use this conda install chardet and pip install --upgrade requests

@jingyiz86
Copy link

conda install chardet

use this conda install chardet and pip install --upgrade requests

this works for me:)

@nathan-tsien
Copy link

conda install chardet

use this conda install chardet and pip install --upgrade requests

yeah, it works.

@drug311
Copy link

drug311 commented Jul 10, 2024

conda install chardet

use this conda install chardet and pip install --upgrade requests

it works.

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