Skip to content

fixed ImportError: cannot import name 'hf_bucket_url' on convert_pytorch_checkpoint_to_tf2.py#5531

Merged
LysandreJik merged 1 commit into
huggingface:masterfrom
mohataher:master
Jul 6, 2020
Merged

fixed ImportError: cannot import name 'hf_bucket_url' on convert_pytorch_checkpoint_to_tf2.py#5531
LysandreJik merged 1 commit into
huggingface:masterfrom
mohataher:master

Conversation

@mohataher

Copy link
Copy Markdown
Contributor

So I installed the latest version of transformers on Google Colab

!pip install transformers 

When trying to invoke the conversion file using

!python /usr/local/lib/python3.6/dist-packages/transformers/convert_pytorch_checkpoint_to_tf2.py .py --help  

Or trying to use

from transformers.file_utils import hf_bucket_url.                                 // works 
from transformers.convert_pytorch_checkpoint_to_tf2 import *.                      // fails

convert_pytorch_checkpoint_to_tf("gpt2", pytorch_file, config_file, tf_file).      

I get this error

 ImportError                               Traceback (most recent call last)

<ipython-input-3-dadaf83ecea0> in <module>()
      1 from transformers.file_utils import hf_bucket_url
----> 2 from transformers.convert_pytorch_checkpoint_to_tf2 import *
      3 
      4 convert_pytorch_checkpoint_to_tf("gpt2", pytorch_file, config_file, tf_file)
/usr/local/lib/python3.6/dist-packages/transformers/convert_pytorch_checkpoint_to_tf2.py in <module>()
     20 import os
     21 
---> 22 from transformers import (
     23     ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     24     BERT_PRETRAINED_CONFIG_ARCHIVE_MAP,

ImportError: cannot import name 'hf_bucket_url'

Turns out, there's a problem in the import of hf_bucket_url. Once fixed, the code ran properly.

fixed ImportError: cannot import name 'hf_bucket_url'

@LysandreJik LysandreJik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, thanks!

@LysandreJik LysandreJik merged commit 1bc1369 into huggingface:master Jul 6, 2020
@Andy824

Andy824 commented Mar 27, 2023

Copy link
Copy Markdown

from transformers.file_utils import default_cache_path, hf_bucket_url
I want to import hf_bucket_url on Colab, but I still got the error
"ImportError: cannot import name 'hf_bucket_url' from 'transformers.file_utils' (/usr/local/lib/python3.9/dist-packages/transformers/file_utils.py)"
Am I do something wrong?

@ther-0319

Copy link
Copy Markdown

from transformers.file_utils import default_cache_path, hf_bucket_url
I want to import hf_bucket_url on Colab, but I still got the error
"ImportError: cannot import name 'hf_bucket_url' from 'transformers.file_utils' (/usr/local/lib/python3.9/dist-packages/transformers/file_utils.py)"
Am I do something wrong?

@amyeroberts

Copy link
Copy Markdown
Contributor

@ther-0319 hf_bucket_url was removed in #18497 ~1.5 years ago. You can use cached_file instead

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

Successfully merging this pull request may close these issues.

5 participants