I have a problem with importing a module from a sub folder.
I am running the main code from directory C:\Users\yeosiz\Desktop\bert_on_stilts
. Folder glue
is inside the mentioned directory and my main code is calling tasks.py
inside the glue
folder. I want to import get_task
and MnliMismatchedProcessor
from tasks.py
.
The structure of the directory:
bert_on_stilts
|_ main.py
|_ glue
|_tasks.py
Here is the code:
import sys
sys.path.insert(0, 'C:/Users/yeosiz/Desktop/bert_on_stilts/glue')
from glue.tasks import get_task, MnliMismatchedProcesso
But I get this error ModuleNotFoundError: No module named 'glue.tasks'
.
I am using python 3.6. Moreover, there is __init__
in the glue
folder.
I have checked the following links to find the solution but I couldn't solve the problem Python 3 import class from subfolder problem, Import module from subfolder, and import main file (not another module) from a subfolder