Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'modeling'

Tags:

python

I'm very new to deep learning and python and I'm trying to recreate the project at https://github.com/Nagakiran1/Extending-Google-BERT-as-Question-and-Answering-model-and-Chatbot

As I saw that in the project there is a file named Bert_QuestionAnswer.ipynb and with data.txt are the only difference I see from the original Bert repository, I just simply loaded it in my google drive and opened it as a notebook to see it in use. When I run the first portion dough I get the ModuleNotFoundError: No module named 'modeling'errror. What library is it part of? For somoebody this was the problem :

It looks like it's trying to import from the github repo source rather than the pip package.

If you are running this in a directory that contains the BERT github repo, try running it elsewhere.

As always many thanks for the help. This is the code of the file that throws me the error :

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from IPython.core.debugger import set_trace
import collections
import json
import math
import os
import random
import modeling
import optimization
import tokenization
import six
import os
import tensorflow as tf


import logging
logging.getLogger('tensorflow').disabled = True
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import warnings
warnings.filterwarnings("ignore")





import time
from pandas import Series
from nltk.tokenize import sent_tokenize
import gensim.downloader as api
from gensim.parsing.preprocessing import remove_stopwords
word_vectors = api.load("glove-wiki-gigaword-100")  # load pre-trained word-vectors from gensim-data
like image 487
Vincenzo Avatar asked Dec 05 '25 12:12

Vincenzo


1 Answers

You need to tell python where this module is:

import sys
sys.path.append("/path/to/your/bert/repo")

Because python will search in his system folders and in the current working directory. If you don't run it in the repo, python doesn't find this module.

like image 199
bb1950328 Avatar answered Dec 07 '25 02:12

bb1950328