Reputation: 11629
I am using Google Colab and the following import doesn't work somehow:
from bert.tokenization import FullTokenizer
I am getting this error:
ModuleNotFoundError: No module named 'bert.tokenization'
I tried to install bert by running the following command:
!pip install --upgrade bert
Any idea how to resolve this error?
Upvotes: 11
Views: 22827
Reputation: 1
You might try this:
!pip install bert-tensorflow
!pip install --upgrade bert
!pip install tokenization
from bert import tokenization
from **bert.tokenization.bert_tokenization** import **FullTokenizer**
tokenizer = FullTokenizer(vocab_file=vocab_file, do_lower_case=do_lower_case)
Upvotes: -1
Reputation: 1
In tf1:
!pip install bert-tokenizer
import bert_tokenizer as tokenization
tokenization.tokenizer.FullTokenizer
Upvotes: 0
Reputation: 1
I could fix it by uninstalling and installing using both pip3 and pip.
!pip3 uninstall -y bert-tensorflow
!pip uninstall -y bert-tensorflow
!pip3 install bert-tensorflow
!pip install bert-tensorflow
Upvotes: 0
Reputation: 1648
or you may use previous version of BERT to avoid further complications (Atleast for now)
!pip install tensorflow-gpu==1.15.0
!pip install bert-tensorflow
from sklearn.model_selection import train_test_split
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
from datetime import datetime
import bert
from bert import run_classifier
from bert import optimization
from bert import tokenization
Upvotes: 0
Reputation: 788
install :
pip install bert-for-tf2
then import,
from bert import bert_tokenization
BertTokenizer = bert_tokenization.FullTokenizer
Upvotes: 4
Reputation: 441
For anyone experiencing this problem with TensorFlow 2.0 and the bert-for-tf2 library, I found out that I was missing some files after using pip3 install. I've posted my solution here:
https://github.com/google-research/bert/issues/638#issuecomment-592488730
Upvotes: 2
Reputation: 147
This worked for me:
!pip install bert-tokenizer
to use:
import bert_tokenizer as tokenizer
NOT import bert_tokenization as tokenization
!!!
Upvotes: -1