ImportError while loading huggingface tokenizer

My broad goal is to be able to run this Keras demo.
I’m trying to load a huggingface tokenizer using the following code:

import os
import re
import json
import string
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tokenizers import BertWordPieceTokenizer
from transformers import BertTokenizer, TFBertModel, BertConfig
slow_tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")

However, I get the following error message:

 Exception ignored in: <function tqdm.__del__ at 0x000001AE43527A60>
    Traceback (most recent call last):
      File "C:\Users\iavta\anaconda3\envs\Ivo\lib\site-packages\tqdm\std.py", line 1152, in __del__
        self.close()
      File "C:\Users\iavta\anaconda3\envs\Ivo\lib\site-packages\tqdm\notebook.py", line 286, in close
        self.disp(bar_style='danger', check_delay=False)
    AttributeError: 'tqdm' object has no attribute 'disp'
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    ~\AppData\Local\Temp/ipykernel_10096/4122314904.py in <module>
          1 # Save the slow pretrained tokenizer
    ----> 2 slow_tokenizer = BertTokenizer.from_pretrained("bert-base-uncased")
          3 #save_path = "bert_base_uncased"
          4 #if not os.path.exists(save_path):
          5 #    os.makedirs(save_path)
    
    ~\anaconda3\envs\Ivo\lib\site-packages\transformers\tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, *init_inputs,
**kwargs)
       1688             else:
       1689                 try:
    -> 1690                     resolved_vocab_files[file_id] = cached_path(
       1691                         file_path,
       1692                         cache_dir=cache_dir,
    
    ~\anaconda3\envs\Ivo\lib\site-packages\transformers\file_utils.py in cached_path(url_or_filename, cache_dir, force_download, proxies, resume_download, user_agent, extract_compressed_file, force_extract, use_auth_token, local_files_only)
       1402     if is_remote_url(url_or_filename):
       1403         # URL, so get it from the cache (downloading if necessary)
    -> 1404         output_path = get_from_cache(
       1405             url_or_filename,
       1406             cache_dir=cache_dir,
    
    ~\anaconda3\envs\Ivo\lib\site-packages\transformers\file_utils.py in get_from_cache(url, cache_dir, force_download, proxies, etag_timeout, resume_download, user_agent, use_auth_token, local_files_only)
       1665             logger.info(f"{url} not found in cache or force_download set to True, downloading to {temp_file.name}")
       1666 
    -> 1667             http_get(url_to_download, temp_file, proxies=proxies, resume_size=resume_size, headers=headers)
       1668 
       1669         logger.info(f"storing {url} in cache at {cache_path}")
    
    ~\anaconda3\envs\Ivo\lib\site-packages\transformers\file_utils.py in http_get(url, temp_file, proxies, resume_size, headers)
       1516     content_length = r.headers.get("Content-Length")
       1517     total = resume_size + int(content_length) if content_length is not None else None
    -> 1518     progress = tqdm(
       1519         unit="B",
       1520         unit_scale=True,
    
    ~\anaconda3\envs\Ivo\lib\site-packages\tqdm\notebook.py in __init__(self, *args, **kwargs)
        240         unit_scale = 1 if self.unit_scale is True else self.unit_scale or 1
        241         total = self.total * unit_scale if self.total else self.total
    --> 242         self.container = self.status_printer(self.fp, total, self.desc, self.ncols)
        243         self.container.pbar = proxy(self)
        244         self.displayed = False
    
    ~\anaconda3\envs\Ivo\lib\site-packages\tqdm\notebook.py in status_printer(_, total, desc, ncols)
        113         # Prepare IPython progress bar
        114         if IProgress is None:  # #187 #451 #558 #872
    --> 115             raise ImportError(
        116                 "IProgress not found. Please update jupyter and ipywidgets."
        117                 " See https://ipywidgets.readthedocs.io/en/stable"
    
    ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html

I’ve already updated Jupyter to 6.4.3 version, and the ipywidgets.

1 Like

I solved this issue by installing the C++ Visual Studio Compiler.